public void resize(WebElement elementToResize, int xOffset, int yOffset) {
try {
if (elementToResize.isDisplayed()) {
Actions action = new Actions(driver);
action.clickAndHold(elementToResize).moveByOffset(xOffset, yOffset).release().build().perform();
} else {
System.out.println("Element was not displayed to drag");
}
} catch (StaleElementReferenceException e) {
System.out.println("Element with " + elementToResize + "is not attached to the page document " + e.getStackTrace());
} catch (NoSuchElementException e) {
System.out.println("Element " + elementToResize + " was not found in DOM " + e.getStackTrace());
} catch (Exception e) {
System.out.println("Unable to resize" + elementToResize + " - " + e.getStackTrace());
}
}
(OR)
moveToElement(WebElement toElement, int xOffset, int yOffset)
Moves the mouse to an offset from the top-left corner of the element.
Actions builder = new Actions(driver);
builder.moveToElement(knownElement, 10, 25).click().build().perform();
No comments:
Post a Comment