PHD Discussions Logo

Ask, Learn and Accelerate in your PhD Research

Question Icon Post Your Answer

Question Icon

6 years ago in Research Methods By Ritesh Tomar

Drag And Drop in selenium

How to create an action chain for the purpose of dragging & dropping a selenium?

All Answers (3 Answers In All)

By Mehak Chaudhary Answered 7 years ago

Ritesh, it’s very simple.
Create a new Selenium WebDriver project in intellij
Create a class and test the codes . Click to avail the codes.https://www.softwaretestingmaterial.com/drag-and-drop-using-actions-class-in-selenium/
Run a test
Here we need to create an Action object and create a chain of events. When a chain is built, we call build(). When perform() is called, the items are popped out and run in order.

By Lalit Mudra Answered 6 years ago

Mehak has already mentioned the codes.To draganddrop, we use two parameters.
1. “Sourcelocator”, an element which we require to drag
2. “Destinationlocator”, an element which we require to drop the first element
In dragAndDropBy method we pass the 3 parameters.
First parameter, “Sourcelocator” is the element which we drag
Second parameter is the x-axis pixel value of the 2nd element.
The third parameter is y-axis pixel value of the 2nd element.

By Fern G Answered 6 years ago

You can perform draganddrop either by dragAndDrop(WebElement src,WebElement dest) method or with source and x & y coordinate. You will find the codes for both the methods in http://learn-automation.com/drag-and-drop-in-selenium-webdriver-using-actions-class/

Your Answer