Java Code Examples for org.openqa.selenium.interactions.Actions#moveByOffset()

The following examples show how to use org.openqa.selenium.interactions.Actions#moveByOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionsTest.java    From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License 5 votes vote down vote up
@Test
public void shouldMoveByOffSet() {

    driver.get("http://guidebook.seleniumacademy.com/Selectable.html");

    WebElement three = driver.findElement(By.name("three"));
    System.out.println("X coordinate: " + three.getLocation().getX()
            + ", Y coordinate: " + three.getLocation().getY());
    Actions actions = new Actions(driver);
    actions.moveByOffset(three.getLocation().getX() + 1, three.
            getLocation().getY() + 1);
    actions.perform();
}
 
Example 2
Source File: DraggableWebElement.java    From bobcat with Apache License 2.0 5 votes vote down vote up
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;
  }

}