@Override public Actions moveByOffset(int xOffset, int yOffset) { super.moveByOffset(xOffset, yOffset); return this; }
private void performMovement(int movement, Orientantion orientantion, Actions builder) { int movementRemains = Math.abs(movement); int movementDirection = Integer.signum(movement); while (movementRemains > 0) { int movementStep = movementRemains >= MOVEMENT_STEP ? MOVEMENT_STEP : 1; if (orientantion == Orientantion.VERTICAL) { builder.moveByOffset(0, movementDirection * movementStep); } else { builder.moveByOffset(movementDirection * movementStep, 0); } movementRemains -= movementStep; } }
Actions movePointerRight = new Actions(driver); movePointerRight.moveByOffset(100, 0).build().perform();
private void performMovement(int movement, Orientantion orientantion, Actions builder) { int movementRemains = Math.abs(movement); int movementDirection = Integer.signum(movement); while (movementRemains > 0) { int movementStep = movementRemains >= MOVEMENT_STEP ? MOVEMENT_STEP : 1; if (orientantion == Orientantion.VERTICAL) { builder.moveByOffset(0, movementDirection * movementStep); } else { builder.moveByOffset(movementDirection * movementStep, 0); } movementRemains -= movementStep; } }
Actions action = new Actions(driver); action.moveToElement(element).build().perform(); action.moveByOffset(1, 1).build().perform();
Actions builder = new Actions(driver); Action action= builder.moveByOffset(40, 40).build();//change the x and y coordinate accordingly action.perform();
public static void moveTo(int x, int y, WebDriver driver) { new Actions(driver).moveByOffset(x, y); }
Actions actions = new Actions(driver); WebElement menuHoverLink = driver.findElement(By.linkText(arg1)); //<span id="m7f8f3e49_ns_menu_INVENTOR_MODULE_a_tnode">Inventory</span> System.out.println("Found the inventory text"); actions.moveToElement(menuHoverLink); actions.moveByOffset(100, 10); Thread.sleep(1000); //actions.moveByOffset(45, 0); WebElement subLink = driver.findElement(By. id("m7f8f3e49_ns_menu_INVENTOR_MODULE_sub_changeapp_SRVITEM_a_tnode")); actions.moveToElement(subLink, 100, 12) .click().perform();
/** * Move horizontally. * @param horizontalOffset * @param verticalOffset */ public static void moveByOffset(int horizontalOffset, int verticalOffset) { getActions().moveByOffset(horizontalOffset, verticalOffset).perform(); }
@Override public void moveByOffset(int xOffset, int yOffset) { getBuilder().moveByOffset(xOffset, yOffset).perform(); }
/** * Move mouse horizontally over page and scroll if necessary to keep it in viewport. * @param offsetInPixel to move mouse horizontally by (negative values move to the left. */ public static void moveMouseHorizontally(int offsetInPixel) { if (offsetInPixel > 0) { getLogger().debug(MARKER_INFO, "move mouse right by " + offsetInPixel); } else if (offsetInPixel < 0) { getLogger().debug(MARKER_INFO, "move mouse left by " + -offsetInPixel); } getActions().moveByOffset(offsetInPixel, 0).perform(); }
/** Hides context menu. */ public void hideContextMenu() { actionsFactory.createAction(seleniumWebDriver).moveByOffset(-1, -1).click().perform(); }
@Override protected Void action(WebKey key, Object... param) throws ExecutionException { Offset offset = (Offset) param[0]; Actions actions = new Actions(driver); actions.moveByOffset(offset.xOffset(), offset.yOffset()); actions.perform(); return null; } };
public void clickAt(String locator, String xOffset, String yOffset) { LOG.keywordAppender().appendLocator(locator); int offSetX = Integer.parseInt(xOffset); int offSetY = Integer.parseInt(yOffset); LOG.keywordAppender() .appendArgument("offSetX", offSetX) .appendArgument("offSetY", offSetY); WebElement el = finder.find(locator); if (el == null) { throw new IllegalStateException(String.format("ERROR: Element %s not found", locator)); } new Actions(driver).moveToElement(el).moveByOffset(offSetX, offSetY).click().perform(); }
@BeforeMethod public void mouseMove() { new Actions(driver).moveByOffset(0, 0).perform(); }
public void mouseOut(String locator) { LOG.keywordAppender().appendLocator(locator); WebElement el = finder.find(locator); if (el == null) { throw new IllegalStateException(String.format("ERROR: Element %s not found", locator)); } Dimension size = el.getSize(); int offsetX = (size.getWidth() / 2 ) + 1; int offsetY = (size.getHeight() / 2 ) + 1; new Actions(driver).moveToElement(el).moveByOffset(offsetX, offsetY).perform(); }
@Override protected Void action(WebKey key, Object... param) throws ExecutionException { WebElement e = key == null ? null : fetcher.fetchElement(key); Offset offset = (Offset) param[0]; Actions actions = new Actions(driver); actions.moveToElement(e); actions.moveByOffset(offset.xOffset(), offset.yOffset()); actions.perform(); return null; } };
public void reorderCategory(String categoryName, int offset) { final WebElement element = findEditableCategoryWith(categoryName); if (null != element) { WebElement dragElement = element.findElement(By.className(MOVE_COMMAND)); builder.moveToElement(element).clickAndHold(dragElement).perform(); // The first move doesn't work properly so do a no-op builder.moveByOffset(0, 0).moveByOffset(0, offset * CATEGORY_INPUT_HEIGHT_PX).perform(); wait.forX(Duration.ofMillis(100)); builder.release().perform(); } } }
public void moveCoverImage() { Actions actions = new Actions(driver); actions.clickAndHold(imageWindowDragging) .clickAndHold() .moveByOffset(-200, -200) .release() .perform(); }
public void submit() { driver.switchTo().defaultContent(); scrollAndClick(postButton); builder.moveByOffset(0, 0).perform(); wait.forElementNotVisible(postButton); Log.log("submit", "message submitted", true); }