Class: Selenium::WebDriver::Interactions::TypingInteraction Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Actions related to pressing keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, type, key) ⇒ TypingInteraction

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TypingInteraction.



32
33
34
35
36
# File 'rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb', line 32

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

Instance Attribute Details

#typeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
# File 'rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb', line 30

def type
  @type
end

Instance Method Details

#assert_source(source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (TypeError)


38
39
40
# File 'rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb', line 38

def assert_source(source)
  raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? KeyInput
end

#assert_type(type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

  • (TypeError)


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

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

  KeyInput::SUBTYPES[type]
end

#encodeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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