Class: Selenium::WebDriver::Interactions::PointerInput

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

Constant Summary collapse

KIND =
{mouse: :mouse, pen: :pen, touch: :touch}.freeze

Instance Attribute Summary collapse

Attributes inherited from InputDevice

#actions, #name

Instance Method Summary collapse

Methods inherited from InputDevice

#add_action, #clear_actions, #create_pause, #no_actions?

Constructor Details

#initialize(kind, name: nil) ⇒ PointerInput

Returns a new instance of PointerInput.



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

def initialize(kind, name: nil)
  super(name)
  @kind = assert_kind(kind)
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



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

def kind
  @kind
end

Instance Method Details

#assert_kind(pointer) ⇒ Object

Raises:

  • (TypeError)


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

def assert_kind(pointer)
  raise TypeError, "#{pointer.inspect} is not a valid pointer type" unless KIND.key? pointer
  KIND[pointer]
end

#create_pointer_cancelObject



59
60
61
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 59

def create_pointer_cancel
  add_action(PointerCancel.new(self))
end

#create_pointer_down(button) ⇒ Object



51
52
53
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 51

def create_pointer_down(button)
  add_action(PointerPress.new(self, :down, button))
end

#create_pointer_move(duration: 0, x: 0, y: 0, element: nil, origin: nil) ⇒ Object



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

def create_pointer_move(duration: 0, x: 0, y: 0, element: nil, origin: nil)
  add_action(PointerMove.new(self, duration, x, y, element: element, origin: origin))
end

#create_pointer_up(button) ⇒ Object



55
56
57
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 55

def create_pointer_up(button)
  add_action(PointerPress.new(self, :up, button))
end

#encodeObject



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

def encode
  return nil if no_actions?
  output = {type: type, id: name, actions: @actions.map(&:encode)}
  output[:parameters] = {pointerType: kind}
  output
end

#typeObject



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

def type
  Interactions::POINTER
end