List of usage examples for org.openqa.selenium Dimension getWidth
public int getWidth()
From source file:MobileElement.java
License:Apache License
public Point getCenter() { Point upperLeft = this.getLocation(); Dimension dimensions = this.getSize(); return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2); }
From source file:com.assertthat.selenium_shutterbug.utils.web.Coordinates.java
License:Open Source License
public Coordinates(WebElement element) { Point point = element.getLocation(); Dimension size = element.getSize(); this.width = size.getWidth(); this.height = size.getHeight(); this.x = point.getX(); this.y = point.getY(); }
From source file:com.assertthat.selenium_shutterbug.utils.web.Coordinates.java
License:Open Source License
public Coordinates(Point point, Dimension size) { this.width = size.getWidth(); this.height = size.getHeight(); this.x = point.getX(); this.y = point.getY(); }
From source file:com.cognifide.aet.job.common.collectors.screen.ScreenCollector.java
License:Apache License
private byte[] getImagePart(byte[] fullPage, WebElement webElement) throws IOException, ProcessingException { InputStream in = new ByteArrayInputStream(fullPage); try {//from ww w . j a v a 2s.c om BufferedImage fullImg = ImageIO.read(in); Point point = webElement.getLocation(); Dimension size = webElement.getSize(); BufferedImage screenshotSection = fullImg.getSubimage(point.getX(), point.getY(), size.getWidth(), size.getHeight()); return bufferedImageToByteArray(screenshotSection); } catch (IOException e) { throw new ProcessingException("Unable to create image from taken screenshot", e); } finally { IOUtils.closeQuietly(in); } }
From source file:com.cognifide.qa.bb.dragdrop.DraggableWebElement.java
License:Apache License
private Point getCurrentLocation() { Point inViewPort = null;// w w w . j av a2s . c om 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; }
From source file:com.cognifide.qa.bb.dragdrop.DroppableWebElement.java
License:Apache License
/** * @return Point in the middle of the drop area. *//*from www . j ava 2 s. com*/ @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; }
From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java
/** * Determines visibility of an element in a window. * @param w// w ww . ja v a 2 s .c o m * @return true if the element is in the window, false if not */ public boolean isElementScrolledIntoView(WebElement w) { if (w == null) { return false; } Point p = w.getLocation(); Dimension d = getDriver().manage().window().getSize(); java.awt.Rectangle r = new java.awt.Rectangle(d.getWidth(), d.getHeight()); java.awt.Point awtPoint = new java.awt.Point(p.x, p.y); return r.contains(awtPoint); }
From source file:com.epam.gepard.selenium.browsers.BrowserHandlerBase.java
License:Open Source License
/** * Sets the browser width and height according to the argument dimension. * * @param dimension the dimension to set *///from w w w .j a v a2 s . c o m public void setBrowserSize(Dimension dimension) { if (dimension == null) { wdu.getSelenium().windowMaximize(); } else { wdu.getSelenium().getEval("window.resizeTo(" + dimension.getWidth() + "," + dimension.getHeight() + "); window.moveTo(0,0);"); } }
From source file:com.galenframework.ide.services.devices.DeviceServiceImpl.java
License:Apache License
private String convertSizeToString(Dimension size) { return size.getWidth() + "x" + size.getHeight(); }
From source file:com.galenframework.page.selenium.WebPageElement.java
License:Apache License
@Override public Rect calculateArea() { if (cachedArea == null) { Point location = getWebElement().getLocation(); Dimension size = getWebElement().getSize(); cachedArea = new Rect(location.getX(), location.getY(), size.getWidth(), size.getHeight()); if (getLocator() != null && getLocator().getCorrections() != null) { cachedArea = correctedRect(cachedArea, getLocator().getCorrections()); }/*from w w w .j a v a2 s .com*/ } return cachedArea; }