class Selenium::WebDriver::Interactions::PointerPress

Actions related to clicking, tapping or pressing the pointer.

@api private

Constants

BUTTONS
DIRECTIONS

Public Class Methods

new(source, direction, button, **opts) click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_press.rb, line 44
def initialize(source, direction, button, **opts)
  super(source)
  @direction = assert_direction(direction)
  @button = assert_button(button)
  @type = @direction
  @opts = opts
end

Public Instance Methods

encode() click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_press.rb, line 52
def encode
  process_opts.merge('type' => type.to_s, 'button' => @button)
end

Private Instance Methods

assert_button(button) click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_press.rb, line 62
def assert_button(button)
  case button
  when Symbol
    raise ArgumentError, "#{button} is not a valid button!" unless BUTTONS.key? button

    BUTTONS[button]
  when Integer
    raise ArgumentError, 'Button number cannot be negative!' if button.negative?

    button
  else
    raise TypeError, "button must be a positive integer or one of #{BUTTONS.keys}, not #{button.class}"
  end
end
assert_direction(direction) click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_press.rb, line 77
def assert_direction(direction)
  raise ArgumentError, "#{direction.inspect} is not a valid button direction" unless DIRECTIONS.key? direction

  DIRECTIONS[direction]
end
assert_source(source) click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_press.rb, line 58
def assert_source(source)
  raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? PointerInput
end