Method: Selenium::WebDriver::PointerActions#drag_and_drop_by

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

#drag_and_drop_by(source, right_by, down_by, device: nil) ⇒ ActionBuilder

A convenience method that performs click-and-hold at the location of the source element, moves by a given offset, then releases the mouse.

Examples:

Drag and drop an element by offset


el = driver.find_element(id: "some_id1")
driver.action.drag_and_drop_by(el, 100, 100).perform

Parameters:

  • source (Selenium::WebDriver::Element)

    Element to emulate button down at.

  • right_by (Integer)

    horizontal move offset.

  • down_by (Integer)

    vertical move offset.

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

    optional name of the PointerInput device with the button that will perform the drag and drop

Returns:



330
331
332
333
334
335
# File 'lib/selenium/webdriver/common/interactions/pointer_actions.rb', line 330

def drag_and_drop_by(source, right_by, down_by, device: nil)
  click_and_hold(source, device: device)
  move_by(right_by, down_by, device: device)
  release(device: device)
  self
end