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.


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

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

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.


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

def kind
  @kind
end

Instance Method Details

#assert_kind(pointer) ⇒ Object

Raises:

  • (TypeError)

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

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

  KIND[pointer]
end

#create_pointer_cancelObject


63
64
65
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 63

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

#create_pointer_down(button) ⇒ Object


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

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


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

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


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

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

#encodeObject


37
38
39
40
41
42
43
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 37

def encode
  return nil if no_actions?

  output = {type: type, id: name, actions: @actions.map(&:encode)}
  output[:parameters] = {pointerType: kind}
  output
end

#typeObject


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

def type
  Interactions::POINTER
end