class Applitools::Selenium::Keyboard

@!visibility private

Attributes

driver[R]
keyboard[R]

Public Class Methods

new(driver, keyboard) click to toggle source

Creates a new Applitools::Selenium::Keyboard instance.

@param [Applitools::Selenium::Driver] driver The driver instance. @param [Selenium::WebDriver::Keyboard] keyboard The keyboard instance.

# File lib/applitools/selenium/keyboard.rb, line 12
def initialize(driver, keyboard)
  @driver = driver
  @keyboard = keyboard
end

Public Instance Methods

press(key) click to toggle source

Press the key.

@param [String] key The key to press.

# File lib/applitools/selenium/keyboard.rb, line 32
def press(key)
  keyboard.press(key)
end
release(key) click to toggle source

Release the key.

@param [String] key The key to release.

# File lib/applitools/selenium/keyboard.rb, line 39
def release(key)
  keyboard.release(key)
end
send_keys(*keys) click to toggle source

Types the keys into a text box.

@param [Array] keys The keys to type into the text box.

# File lib/applitools/selenium/keyboard.rb, line 20
def send_keys(*keys)
  active_element = Applitools::Selenium::Element.new(driver, driver.switch_to.active_element)
  current_control = active_element.region
  Selenium::WebDriver::Keys.encode(keys).each do |key|
    driver.user_inputs << Applitools::Base::TextTrigger.new(key.to_s, current_control)
  end
  keyboard.send_keys(*keys)
end