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.



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

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.



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

def type
  @type
end

Instance Method Details

#assert_type(type) ⇒ Object

Raises:

  • (TypeError)


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

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

#encodeObject



57
58
59
# File 'lib/selenium/webdriver/common/interactions/key_input.rb', line 57

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