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)


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

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

#create_pointer_cancelObject



61
62
63
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 61

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

#create_pointer_down(button) ⇒ Object



53
54
55
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 53

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



49
50
51
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 49

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



57
58
59
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 57

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

#encodeObject



37
38
39
40
41
42
# 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