Drag an element to the given position or destination element.

Usage

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

Example

Or run locally with:
git clone https://github.com/nightwatchjs/nightwatch-examples.git
cd nightwatch-examples
npm install
npx nightwatch tests/api/dragAndDrop.js

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