Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

How to automate drag & drop functionality using Selenium WebDriver in java?

1 Answer

0 votes
by (62.9k points)

Here is a piece of code below, which include a dragAndDrop(x,y) method of Action class, that takes two arguments x and y, x being source location and y being target location. (x,y).

 try {

         System.out.println("Drag and Drom started :");


                Actions actions = new Actions(webdriver);

                WebElement srcElement = webdriver.findElement(By.xpath("source Xpath"));

                WebElement targetElement = webdriver.findElement(By.xpath("Target Xpath"));

                actions.dragAndDrop(srcElement, targetElement); 


                System.out.println("Drag and Drom complated :");

            } catch (Exception e) {




Browse Categories