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

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

Direct Known Subclasses

KeyInput, NoneInput, PointerInput

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ InputDevice

Returns a new instance of InputDevice.



26
27
28
29
# File 'lib/selenium/webdriver/common/interactions/input_device.rb', line 26

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

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



24
25
26
# File 'lib/selenium/webdriver/common/interactions/input_device.rb', line 24

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/selenium/webdriver/common/interactions/input_device.rb', line 24

def name
  @name
end

Instance Method Details

#add_action(action) ⇒ Object

Raises:

  • (TypeError)


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

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

#clear_actionsObject



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

def clear_actions
  @actions.clear
end

#create_pause(duration = nil) ⇒ Object



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

def create_pause(duration = nil)
  add_action(Pause.new(self, duration))
end

#no_actions?Boolean

Determine if only pauses are present

Returns:

  • (Boolean)


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

def no_actions? # Determine if only pauses are present
  actions = @actions.reject { |action| action.type == Interaction::PAUSE }
  actions.empty?
end