Drag and Drop

Home >> Tags >> Drag and Drop

Drag and Drop using Webdriver Action Class

We have taken example program to perform drag and drop. In the below example, as the DragAndDrop divs are in a Frame, First we need to switch to the frame before performing drag and drop. And then we also need to check for the availability of SourceElement and DestinationElements.

Syntax for drag and drop
Actions action = new Actions(driver);
action.dragAndDrop(Sourcelocator, Destinationlocator).build().perform();

We can also make it as below:
(new Actions(driver)).dragAndDrop(element, target).perform();