Thursday, August 29, 2013

Drag and Drop the elements(With in the web page only)



WebElement dragElement = driver.findElement(By
     .xpath(""));
WebElement dropElement = driver.findElement(By
     .xpath(""));
Actions action = new Actions(driver);
action.dragAndDrop(dragElement, dropElement).perform();

(OR)


public void dragAndDrop(WebDriver driver, String fromObjectLocator, String toObjectLocator) throws Exception {
try {

Actions act = new Actions(driver);

WebElement fromElement = findElement(driver, fromObjectLocator);

WebElement toElement = findElement(driver, toObjectLocator);

act.dragAndDrop(fromElement, toElement).build().perform();

APP_LOGS.info("<< Drag drop action is performed >>");

act.release();

} catch (Exception e) {

APP_LOGS.error(">>>Error while performing dragAndDrop <<<" + e.getMessage());
}

}

No comments:

Post a Comment