/** * Returns new instance with resized borders form bottom right corner. * The top left point will stay unchanged, other borders will change. */ public Locations resizeFromBottomRight(int byXPixels, int byYPixels) { return new Locations(topLeft, topRight.moveBy(byXPixels, 0), bottomLeft.moveBy(0, byYPixels), bottomRight.moveBy(byXPixels, byYPixels)); }
/** * Returns Locations of input element. * * @see Locations */ public static Locations getLocations(WebElement root) { Preconditions.checkNotNull(root, "The element cannot be null."); Point topLeft = root.getLocation(); Dimension dimension = root.getSize(); Point topRight = topLeft.moveBy(dimension.getWidth(), 0); Point bottomRight = topRight.moveBy(0, dimension.getHeight()); Point bottomLeft = topLeft.moveBy(0, dimension.getHeight()); return new Locations(topLeft, topRight, bottomLeft, bottomRight); }
private List<ExcludedElement> getExcludeElementsFromWebElements(List<WebElement> webElements) { List<ExcludedElement> excludeExcludedElements = new ArrayList<>(webElements.size()); Point screenshotOffset = isSelectorPresent() ? webDriver.findElement(getLocator()).getLocation() : new Point(0, 0); for (WebElement webElement : webElements) { Point point = webElement.getLocation() .moveBy(-screenshotOffset.getX(), -screenshotOffset.getY()); excludeExcludedElements.add(new ExcludedElement( new java.awt.Point(point.getX(), point.getY()), new java.awt.Dimension(webElement.getSize().width, webElement.getSize().height))); } return excludeExcludedElements; }
private List<ExcludedElement> getExcludeElementsFromWebElements(List<WebElement> webElements) { List<ExcludedElement> excludeExcludedElements = new ArrayList<>(webElements.size()); Point screenshotOffset = isSelectorPresent() ? webDriver.findElement(getLocator()).getLocation() : new Point(0, 0); for (WebElement webElement : webElements) { Point point = webElement.getLocation() .moveBy(-screenshotOffset.getX(), -screenshotOffset.getY()); excludeExcludedElements.add(new ExcludedElement( new java.awt.Point(point.getX(), point.getY()), new java.awt.Dimension(webElement.getSize().width, webElement.getSize().height))); } return excludeExcludedElements; }
@Test public void drawFace() { Point head = new Point(220, 450); Point leftEye = head.moveBy(-50, -50); Point rightEye = head.moveBy(50, -50); Point mouth = head.moveBy(0, 50); drawCircle(driver, head, 150, 30); drawCircle(driver, leftEye, 20, 20); drawCircle(driver, rightEye, 20, 20); drawCircle(driver, mouth, 40, 20); try { Thread.sleep(5000); } catch (InterruptedException ign) {} }
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; }