Drag an element to the given position or destination element.

Usage

.dragAndDrop(selector, destination, callback)
.dragAndDrop(using, selector, destination, callback)

Parameters

Name Type description
using
Optional
string

The locator strategy to use. See W3C Webdriver - locator strategies

selector string|object

The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies element properties.

destination string

Either another element to drag to (will drag to the center of the element), or an {x, y} object specifying the offset to drag by, in pixels.

callback function

Callback function which is called with the result value; not required if using await operator.

Returns

Type description
* null

Example

module.exports = {
  demoTest(browser) {
    browser.dragAndDrop('#main', {x: 100, y:100})
  }

  // using an Element ID as a destination
  demoTestAsync: async function(browser) {
    const destination = await browser.findElement('#upload');
    browser.dragAndDrop('#main', destination.getId());
  }
}