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.


47
48
49
50
51
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 47

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.


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

def type
  @type
end

Instance Method Details

#assert_type(type) ⇒ Object

Raises:

  • (TypeError)

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

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

  KeyInput::SUBTYPES[type]
end

#encodeObject


59
60
61
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 59

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