Class: Selenium::WebDriver::Interactions::InputDevice Private

Inherits:
Object
  • Object
show all
Defined in:
rb/lib/selenium/webdriver/common/interactions/input_device.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.

Superclass for the input device sources Manages Array of Interaction instances for the device

Direct Known Subclasses

KeyInput, NoneInput, PointerInput, WheelInput

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ InputDevice

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 InputDevice.



35
36
37
38
# File 'rb/lib/selenium/webdriver/common/interactions/input_device.rb', line 35

def initialize(name = nil)
  @name = name || SecureRandom.uuid
  @actions = []
end

Instance Attribute Details

#actionsObject (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.



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

def actions
  @actions
end

#nameObject (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.



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

def name
  @name
end

#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.



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

def type
  @type
end

Instance Method Details

#add_action(action) ⇒ 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)


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

def add_action(action)
  raise TypeError, "#{action.inspect} is not a valid action" unless action.class < Interaction

  @actions << action
end

#clear_actionsObject

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.



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

def clear_actions
  @actions.clear
end

#create_pause(duration = 0) ⇒ 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.



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

def create_pause(duration = 0)
  add_action(Pause.new(self, duration))
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.



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

def encode
  {type: type, id: name, actions: @actions.map(&:encode)} unless @actions.empty?
end