Class: Selenium::WebDriver::Interactions::PointerPress
- Inherits:
-
Interaction
- Object
- Interaction
- Selenium::WebDriver::Interactions::PointerPress
- Defined in:
- lib/selenium/webdriver/common/interactions/pointer_input.rb
Overview
PointerInput
Constant Summary collapse
- BUTTONS =
{left: 0, middle: 1, right: 2}.freeze
- DIRECTIONS =
{down: :pointerDown, up: :pointerUp}.freeze
Constants inherited from Interaction
Instance Attribute Summary
Attributes inherited from Interaction
Instance Method Summary collapse
- #assert_button(button) ⇒ Object
- #assert_direction(direction) ⇒ Object
- #encode ⇒ Object
-
#initialize(source, direction, button) ⇒ PointerPress
constructor
A new instance of PointerPress.
- #type ⇒ Object
Constructor Details
#initialize(source, direction, button) ⇒ PointerPress
Returns a new instance of PointerPress.
72 73 74 75 76 |
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 72 def initialize(source, direction, ) super(source) @direction = assert_direction(direction) @button = () end |
Instance Method Details
#assert_button(button) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 82 def () if .is_a? Symbol raise TypeError, "#{.inspect} is not a valid button!" unless BUTTONS.key? = BUTTONS[] end raise ArgumentError, 'Button number cannot be negative!' unless >= 0 end |
#assert_direction(direction) ⇒ Object
93 94 95 96 97 |
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 93 def assert_direction(direction) raise TypeError, "#{direction.inspect} is not a valid button direction" unless DIRECTIONS.key? direction DIRECTIONS[direction] end |
#encode ⇒ Object
99 100 101 |
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 99 def encode {type: type, button: @button} end |
#type ⇒ Object
78 79 80 |
# File 'lib/selenium/webdriver/common/interactions/pointer_input.rb', line 78 def type @direction end |