Sha256: 8e4191d9ea6cc6b3830ed25881a29adeb2bd39b0f5583a6b7d7a6ee554aca1e4

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

module Selenium
  module WebDriver

    # @api private
    class Keyboard

      def initialize(bridge)
        @bridge = bridge
      end

      def send_keys(*keys)
        @bridge.getActiveElement.send_keys(*keys)
      end

      #
      # Release a modifier key
      #
      # @see Selenium::WebDriver::Keys
      #

      def press(key)
        assert_modifier key
        @bridge.sendModifierKeyToActiveElement Keys[key], true
      end

      #
      # Release a modifier key
      #
      # @see Selenium::WebDriver::Keys
      #

      def release(key)
        assert_modifier key
        @bridge.sendModifierKeyToActiveElement Keys[key], false
      end

      private

      MODIFIERS = [:control, :shift, :alt, :command, :meta]

      def assert_modifier(key)
        unless MODIFIERS.include? key
          raise Error::UnsupportedOperationError,
            "#{key.inspect} is not a modifier key, expected one of #{MODIFIERS.inspect}"
        end
      end

    end # Keyboard
  end # WebDriver
end  # Selenium

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
selenium-webdriver-2.8.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.7.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.6.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.5.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.4.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.3.2 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.3.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.2.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.1.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.0.1 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-2.0.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-0.2.2 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-0.2.1 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-0.2.0 lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-0.2.0.dev lib/selenium/webdriver/common/keyboard.rb
selenium-webdriver-0.1.4 lib/selenium/webdriver/common/keyboard.rb