Method: Selenium::WebDriver::PointerActions#move_by

Defined in:
lib/selenium/webdriver/common/interactions/pointer_actions.rb

#move_by(right_by, down_by, device: nil, duration: default_move_duration) ⇒ ActionBuilder

Moves the pointer from its current position by the given offset.

The viewport is not scrolled if the coordinates provided are outside the viewport. MoveTargetOutOfBoundsError will be raised if the offsets are outside the viewport

Examples:

Move the pointer to a certain offset from its current position


driver.action.move_by(100, 100).perform

Parameters:

  • right_by (Integer)

    horizontal offset. A negative value means moving the pointer left.

  • down_by (Integer)

    vertical offset. A negative value means moving the pointer up.

  • device (Symbol || String) (defaults to: nil)

    optional name of the PointerInput device to move

Returns:

Raises:

  • (MoveTargetOutOfBoundsError)

    if the provided offset is outside the document’s boundaries.



125
126
127
128
129
130
131
132
133
134
# File 'lib/selenium/webdriver/common/interactions/pointer_actions.rb', line 125

def move_by(right_by, down_by, device: nil, duration: default_move_duration, **)
  pointer = pointer_input(device)
  pointer.create_pointer_move(duration: duration,
                              x: Integer(right_by),
                              y: Integer(down_by),
                              origin: Interactions::PointerMove::POINTER,
                              **)
  tick(pointer)
  self
end