Drag and Drop Handing

import org.openqa.selenium.interactions.Actions;
/*


*/

WebElement draggable=driver.findElement(By.xpath(".//*[@id='draggable']/p"));
 WebElement dropable=driver.findElement(By.xpath(".//*[@id='droppable']/p"));

    Actions action= new Actions(driver);

    action.clickAndHold(draggable).build().perform();
    action.moveToElement(dropable).build().perform();
    action.release(dropable).build().perform();


or

//above  mentioned 3 lines can be merge in a single line.

action.clickAndHold(draggable).moveToElement(dropable).release().build().perform();

Post a Comment

0 Comments