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


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

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

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions


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

def actions
  @actions
end

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

Instance Method Details

#add_action(action) ⇒ Object

Raises:

  • (TypeError)

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

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

#clear_actionsObject


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

def clear_actions
  @actions.clear
end

#create_pause(duration = nil) ⇒ Object


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

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

#no_actions?Boolean

Determine if only pauses are present


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

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