-1

Please help for solution other then action class..i have to drag and drop element ;from element; to 'To element' in java

pravin
  • 15
  • 8
  • 2
    Possible duplicate of [How to automate drag & drop functionality using Selenium WebDriver](http://stackoverflow.com/questions/14210051/how-to-automate-drag-drop-functionality-using-selenium-webdriver) – Madhan Jul 06 '16 at 13:31

1 Answers1

0

I suggest you use 'Robot' for drag and drop. It's quite straight forward. An example of how I'm using it which may actually work for you...

// Location of your first element
Point coordinates1 = driver.findElement(By.xpath("your element xpath")).getLocation();

// Location of your second Element
Point coordinates2 = driver.findElement(By.xpath("your element xpath")).getLocation();

    Robot robot = new Robot();
    robot.setAutoDelay(2000);
    robot.setAutoWaitForIdle(true);

    // go to the location of the first element
    robot.mouseMove(coordinates1.getX(), coordinates1.getY());

    robot.delay(500);

    // Press the mouse on the first location
    robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);

    robot.delay(500);

    // Move the mouse to the second location
    robot.mouseMove(coordinates2.getX(), coordinates2.getY());

    // Release the mouse on the second location
    robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK)
Moser
  • 287
  • 2
  • 12