Coordinates(org.openqa.selenium.interactions.Coordinates coords) { this.inViewport = coords.inViewPort() == null ? null : new Point(coords.inViewPort()); this.remote = null; this.lock = null; }
protected Optional<WebElement> getTargetElement() { if (where == null) { return Optional.empty(); } if (!(where.getCoordinates().getAuxiliary() instanceof WebElement)) { throw new IllegalStateException(String.format( "%s: Unable to find element to use: %s", this, where.getCoordinates())); } return Optional.of((WebElement) where.getCoordinates().getAuxiliary()); } }
/** * Extracts the location relative to the entire page from the coordinates * (e.g. as opposed to viewport) * * @param coordinates The coordinates from which location is extracted. * @return The location relative to the entire page */ public static Location getPageLocation(Coordinates coordinates) { if (coordinates == null) { return null; } Point p = coordinates.onPage(); return new Location(p.getX(), p.getY()); }
/** * {@inheritDoc} */ @Override public void mouseMove(org.openqa.selenium.interactions.Coordinates coords) { robot.get().mouseMove(coords.inViewPort()); }
/** * {@inheritDoc} */ @Override public void click(org.openqa.selenium.interactions.Coordinates coords) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } robot.get().mouseClick(MouseButton.LEFT); }
/** * {@inheritDoc} */ @Override public void mouseMove(org.openqa.selenium.interactions.Coordinates coords, long xOffset, long yOffset) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } else { robot.get().mouseMoveBy(xOffset, yOffset); } }
/** * {@inheritDoc} */ @Override public void mouseUp(org.openqa.selenium.interactions.Coordinates coords) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } robot.get().mouseRelease(MouseButton.LEFT); }
/** * {@inheritDoc} */ @Override public void contextClick(org.openqa.selenium.interactions.Coordinates coords) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } robot.get().mouseClick(MouseButton.RIGHT); }
/** * {@inheritDoc} */ @Override public void mouseDown(org.openqa.selenium.interactions.Coordinates coords) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } robot.get().mousePress(MouseButton.LEFT); }
/** * {@inheritDoc} */ @Override public void doubleClick(org.openqa.selenium.interactions.Coordinates coords) { if (coords != null) { robot.get().mouseMove(coords.inViewPort()); } robot.get().mouseClick(MouseButton.LEFT); robot.get().mouseClick(MouseButton.LEFT); }
/** * Extracts the location relative to the <b>viewport</b> from the * coordinates (e.g. as opposed to the entire page). * * @param coordinates The coordinates from which location is extracted. * @return The location relative to the viewport. */ public static Location getViewportLocation(Coordinates coordinates) { if (coordinates == null) { return null; } Point p = coordinates.inViewPort(); return new Location(p.getX(), p.getY()); }
/** /** * Scroll to element (applied only for desktop). * Useful for desktop with React */ public void scrollTo() { if (Configuration.getDriverType().equals(SpecialKeywords.MOBILE)) { LOGGER.debug("scrollTo javascript is unsupported for mobile devices!"); return; } try { Locatable locatableElement = (Locatable) findElement(EXPLICIT_TIMEOUT); // [VD] onScreen should be updated onto onPage as only 2nd one // returns real coordinates without scrolling... read below material // for details // https://groups.google.com/d/msg/selenium-developers/nJR5VnL-3Qs/uqUkXFw4FSwJ // [CB] onPage -> inViewPort // https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/remote/RemoteWebElement.java?r=abc64b1df10d5f5d72d11fba37fabf5e85644081 int y = locatableElement.getCoordinates().inViewPort().getY(); int offset = R.CONFIG.getInt("scroll_to_element_y_offset"); ((JavascriptExecutor) getDriver()).executeScript("window.scrollBy(0," + (y - offset) + ");"); } catch (Exception e) { //do nothing } }
private Point getCurrentLocation() { Point inViewPort = null; switcher.switchTo(getFramePath()); try { Dimension size = webElement.getSize(); inViewPort = ((Locatable) webElement).getCoordinates().inViewPort() .moveBy(size.getWidth() / 2, size.getHeight() / 2); } finally { switcher.switchBack(); } return inViewPort; }
private Point getCurrentLocation() { Point inViewPort = null; switcher.switchTo(getFramePath()); try { Dimension size = webElement.getSize(); inViewPort = ((Locatable) webElement).getCoordinates().inViewPort() .moveBy(size.getWidth() / 2, size.getHeight() / 2); } finally { switcher.switchBack(); } return inViewPort; }
/** * @return Point in the middle of the drop area. */ @Override public Point getCurrentLocation() { Point inViewPort = null; switcher.switchTo(getFramePath()); try { Dimension size = dropArea.getSize(); inViewPort = ((Locatable) dropArea).getCoordinates().inViewPort() .moveBy(size.getWidth() / 2, size.getHeight() / 2); } finally { switcher.switchBack(); } return inViewPort; }
/** * @return Point in the middle of the drop area. */ @Override public Point getCurrentLocation() { Point inViewPort = null; switcher.switchTo(getFramePath()); try { Dimension size = dropArea.getSize(); inViewPort = ((Locatable) dropArea).getCoordinates().inViewPort() .moveBy(size.getWidth() / 2, size.getHeight() / 2); } finally { switcher.switchBack(); } return inViewPort; }