WebDriver adjustBrowserPosition(Config config, WebDriver driver) { if (config.browserPosition() != null) { log.info("Set browser position to " + config.browserPosition()); String[] coordinates = config.browserPosition().split("x"); int x = Integer.parseInt(coordinates[0]); int y = Integer.parseInt(coordinates[1]); Point target = new Point(x, y); Point current = driver.manage().window().getPosition(); if (!current.equals(target)) { driver.manage().window().setPosition(target); } } return driver; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Locations other = (Locations) obj; if (!this.topLeft.equals(other.topLeft)) { return false; } if (!this.topRight.equals(other.topRight)) { return false; } if (!this.bottomLeft.equals(other.bottomLeft)) { return false; } if (!this.bottomRight.equals(other.bottomRight)) { return false; } return true; }
@Override protected boolean checkForEquality(Point value1, Point value2) { GaleniumReportUtil.getLogger().trace("comparing locations: '" + value1 + "' <> '" + value2 + "'"); return value1.equals(value2); }
public Point call() throws Exception { currentLocation = element.getLocation(); if (currentLocation.equals(expectedLocation)) { return expectedLocation; } return null; }
/** * Condition that checks if animation of provided WebElement finished. * * @param element WebElement to be checked * @return ExpectedCondition representing the above check */ public ExpectedCondition<WebElement> hasAnimationFinished(final WebElement element) { final Deque<Point> locations = new ArrayDeque<>(); return webDriver -> { Point currentLocation = element.getLocation(); boolean animationStopped = false; if (!locations.isEmpty()) { animationStopped = locations.peekFirst().equals(currentLocation); } locations.addFirst(currentLocation); return animationStopped ? element : null; }; }
/** * Condition that checks if animation of provided WebElement finished. * * @param element WebElement to be checked * @return ExpectedCondition representing the above check */ public ExpectedCondition<WebElement> hasAnimationFinished(final WebElement element) { final Deque<Point> locations = new ArrayDeque<>(); return webDriver -> { Point currentLocation = element.getLocation(); boolean animationStopped = false; if (!locations.isEmpty()) { animationStopped = locations.peekFirst().equals(currentLocation); } locations.addFirst(currentLocation); return animationStopped ? element : null; }; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } Rectangle rectangle = (Rectangle) o; if (! getPoint().equals(rectangle.getPoint())) { return false; } return getDimension().equals(rectangle.getDimension()); }