How to simulate the Drag and Drop on this page

1 Answer(s)

Hi dvenugopalrao,

For Drag and Drop you need to use Actions class.

In your above code you are inspecting the correct element. Next thing you need to inspect the element where you need to drop the element which is the “sortable2″.

And now you just need to use the dragAndDrop method of Actions class.


driver.get("http://jqueryui.com/sortable/");

driver.findElement(By.xpath(".//*[@id='content']/div[1]/ul/li[2]/a")).click();
driver.switchTo().frame(0);

WebElement sortable1 = driver.findElement(By.xpath(".//*[@id='sortable1']/li[1]"));
WebElement sortable2 = driver.findElement(By.xpath(".//*[@id='sortable2']"));
Actions builder = new Actions(driver);

builder.dragAndDrop(sortable1, sortable2).perform();

rajesh Supporter Answered on December 26, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.