DragNDrop
DragNDrop using Elements on screen:
public static void dragNDropByLongpress(WebElement element1, WebElement element2) {
TouchAction dragNDrop = new TouchAction(driver).longPress(element1).moveTo(element2).release();
dragNDrop.perform();
}test.java
$ helper.dragNDropByLongpress(sourceElement, destinationElement);DragNDrop using XY-Coordinates of screen:
public static void dragNDropByCoordinatesTest(AndroidElement element1, AndroidElement element2) {
Point center1 = element1.getCenter();
Point center2 = element2.getCenter();
TouchAction action = new TouchAction(driver).longPress(center1.x, center1.y).moveTo(center2.x, center2.y).release();
action.perform();
}Last updated