Method: Selenium::WebDriver::PointerActions#drag_and_drop

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

#drag_and_drop(source, target, device: nil) ⇒ ActionBuilder

A convenience method that performs click-and-hold at the location of the source element, moves to the location of the target element, then releases the mouse.

Examples:

Drag and drop one element onto another


el1 = driver.find_element(id: "some_id1")
el2 = driver.find_element(id: "some_id2")
driver.action.drag_and_drop(el1, el2).perform

Parameters:

  • source (Selenium::WebDriver::Element)

    element to emulate button down at.

  • target (Selenium::WebDriver::Element)

    element to move to and release the mouse at.

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

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

Returns:

[View source]

306
307
308
309
310
311
# File 'lib/selenium/webdriver/common/interactions/pointer_actions.rb', line 306

def drag_and_drop(source, target, device: nil)
  click_and_hold(source, device: device)
  move_to(target, device: device)
  release(device: device)
  self
end