Class: Selenium::WebDriver::Interactions::KeyInput::TypingInteraction

Inherits:
Interaction
  • Object
show all
Defined in:
lib/selenium/webdriver/common/interactions/key_input.rb

Constant Summary

Constants inherited from Interaction

Interaction::PAUSE

Instance Attribute Summary collapse

Attributes inherited from Interaction

#source

Instance Method Summary collapse

Constructor Details

#initialize(source, type, key) ⇒ TypingInteraction

Returns a new instance of TypingInteraction.



44
45
46
47
48
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 44

def initialize(source, type, key)
  super(source)
  @type = assert_type(type)
  @key = Keys.encode_key(key)
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



42
43
44
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 42

def type
  @type
end

Instance Method Details

#assert_type(type) ⇒ Object

Raises:

  • (TypeError)


50
51
52
53
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 50

def assert_type(type)
  raise TypeError, "#{type.inspect} is not a valid key subtype" unless KeyInput::SUBTYPES.key? type
  KeyInput::SUBTYPES[type]
end

#encodeObject



55
56
57
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 55

def encode
  {type: @type, value: @key}
end