URL - http://www.seleniumeasy.com/test/drag-and-drop-demo.html
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir")+"//drivers//chrome//chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.seleniumeasy.com/test/drag-and-drop-demo.html");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement itemToBeDragged=driver.findElement(By.xpath(" (//h3[contains(.,'Items to Drag')]//following-sibling::span)[1]"));
WebElement
whereToBeDragged=driver.findElement(By.xpath("//div[@id='mydropzone']"));
Actions action=new Actions(driver);
Action dragAndDrop = action.clickAndHold(itemToBeDragged).moveToElement(whereToBeDragged).release(whereToBeDragged).build();
dragAndDrop.perform();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.close();
Using above code I am not able to drag and drop the element. Please help !