List of usage examples for org.openqa.selenium Point Point
public Point(int x, int y)
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:budget.WebDriverManager.java
private static void refreshAccountsAmEx() { int attempts = 3; int attempt = 1; Boolean isDownloaded = false; List<String> credentials = getCredentials(7); while ((attempt <= attempts) && !isDownloaded) { try {/*from ww w .ja v a2 s. co m*/ driver = new FirefoxDriver(); driver.manage().window().setPosition(new Point(-2000, 0)); wait = new WebDriverWait(driver, timeout); java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit") .setLevel(java.util.logging.Level.OFF); java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF); driver.get("Http://www.americanexpress.com"); driver.findElement(By.id("Username")).clear(); driver.findElement(By.id("Username")).sendKeys(credentials.get(0)); driver.findElement(By.id("Password")).clear(); driver.findElement(By.id("Password")).sendKeys(credentials.get(1)); driver.findElement(By.id("loginLink")).click(); //Total amount waitAndClick(driver, wait, By.id("avlbleCreditAsterick")); waitForElement(wait, By.id("availCreditValue")); String balanceStr = driver.findElement(By.id("availCreditValue")).getText(); String limitStr = driver.findElement(By.id("ttlCreditValue")).getText(); double amount = convertStringAmountToDouble(balanceStr) - convertStringAmountToDouble(limitStr); addTotal(stmt, getTimestamp(), 7, amount, taLog); //Transactions waitAndClick(driver, wait, By.id("MYCA_PC_Statements2")); waitAndClick(driver, wait, By.id("expandTP")); waitAndClick(driver, wait, By.id("anon_7"));//January 1 to Present wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.id("expandTP")))); //Pending transactions driver.findElement(By.id("recentTrans")).click(); waitForElement(wait, By.className("pendingetd-helptxt")); runQueryAmEx(driver, wait, true); //Posted transactions runQueryAmEx(driver, wait, false); driver.findElement(By.id("iNLogBtn")).click(); driver.quit(); isDownloaded = true; } catch (Exception ex) { driver.quit(); trace(ex.getMessage(), taLog); clearBatch(stmt); attempt++; } ; } trace((isDownloaded ? "Downloaded" : "Not downloaded") + " from " + attempt + ((attempt == 1) ? " attempt" : " attemps"), taLog); //Execution executeBatch(stmt, taLog); }
From source file:cc.kune.selenium.KuneSeleniumDefaults.java
License:GNU Affero Public License
/** * Resize.// w w w. j a v a 2s . c om */ public void resize() { // Some others tested values: // 1024,769 // 840,770 // 806,707 webdriver.manage().window().setPosition(new Point(0, 0)); webdriver.manage().window().setSize(new Dimension(806, 707)); // Before we were using: // final JavascriptExecutor js = (JavascriptExecutor) webdriver; // js.executeScript("window.resizeTo(806,707); window.moveTo(0,0);"); }
From source file:cc.kune.selenium.KuneSeleniumDefaults.java
License:GNU Affero Public License
/** * Sets the position.//from www .j av a2 s .co m * * @param x * the x * @param y * the y */ public void setPosition(final int x, final int y) { webdriver.manage().window().setPosition(new Point(x, y)); }
From source file:com.ariatemplates.seleniumjavarobot.calibrator.Calibrator.java
License:Apache License
public static Point calibrate(RobotizedBrowser robotizedBrowser, int colorTolerance) throws InterruptedException { Server server = new Server(0); try {//ww w .j a va 2s.co m server.setHandler(new CalibrationHandler()); server.start(); robotizedBrowser.browser.get("http://127.0.0.1:" + server.getURI().getPort() + "/"); server.stop(); } catch (Exception e) { throw new RuntimeException(e); } // call the calibration script: @SuppressWarnings("unchecked") Map<String, Long> jsInfos = (Map<String, Long>) robotizedBrowser.browser.executeScript(CALIBRATOR_SCRIPT); int width = jsInfos.get("width").intValue(); int height = jsInfos.get("height").intValue(); SeleniumJavaRobot.log(String.format("Viewport size: %d x %d", width, height)); Point windowPosition = robotizedBrowser.browser.getWindowPosition(); Dimension windowSize = robotizedBrowser.browser.getWindowSize(); Rectangle windowRectangle = new Rectangle(windowPosition.x, windowPosition.y, windowSize.width, windowSize.height); SeleniumJavaRobot.log("Browser window rectangle: " + windowRectangle); // Give some time to the browser to display the expected color: Thread.sleep(500); // look for the rectangle full of the expected color: Rectangle rect = RectangleFinder.findRectangle(robotizedBrowser.robot, CALIBRATION_COLOR, windowRectangle, width - 2 * BORDER, height - 2 * BORDER, colorTolerance); if (rect == null) { throw new RuntimeException("Calibration failed."); } return new Point(rect.x - BORDER - windowPosition.x, rect.y - BORDER - windowPosition.y); }
From source file:com.assertthat.selenium_shutterbug.utils.image.ImageProcessorTest.java
License:Apache License
@Test public void testHighlight() throws IOException { Point point = new Point(9, 33); Dimension size = new Dimension(141, 17); Coordinates coords = new Coordinates(point, size); BufferedImage clearImage = ImageIO .read(Thread.currentThread().getContextClassLoader().getResourceAsStream("clearImage.png")); BufferedImage highlightedExpectedImage = ImageIO .read(Thread.currentThread().getContextClassLoader().getResourceAsStream("highlightedImage.png")); BufferedImage highlightedActualImage = ImageProcessor.highlight(clearImage, coords, Color.red, 3); assertTrue("Images are not equal after highlighting", ImageProcessor.imagesAreEquals(highlightedExpectedImage, highlightedActualImage, 0.0)); }
From source file:com.assertthat.selenium_shutterbug.utils.web.Browser.java
License:Open Source License
public Coordinates getBoundingClientRect(WebElement element) { String script = FileUtil.getJsScript(RELATIVE_COORDS_JS); ArrayList<String> list = (ArrayList<String>) executeJsScript(RELATIVE_COORDS_JS, element); Point start = new Point(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1))); Dimension size = new Dimension(Integer.parseInt(list.get(2)), Integer.parseInt(list.get(3))); return new Coordinates(start, size); }
From source file:com.dukescript.impl.selenium.DomNodeWebElement.java
License:Open Source License
@Override public Point getLocation() { final CountDownLatch countDownLatch = new CountDownLatch(1); final Point[] result = new Point[1]; ctx.execute(new Runnable() { @Override//w w w.j av a 2 s. com public void run() { result[0] = new Point(getLeft_impl(nativeElement), getTop_impl(nativeElement)); countDownLatch.countDown(); } }); try { countDownLatch.await(); return result[0]; } catch (InterruptedException ex) { Logger.getLogger(DukeScriptBrowser.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:com.elastica.driver.WebUtility.java
License:Apache License
/** * Resize window to given dimensions./*from w w w .jav a 2 s. c o m*/ * * @param width * @param height */ public void resizeWindow(final int width, final int height) { try { TestLogging.logWebStep(null, "Resize browser window to width " + width + " height " + height, false); Dimension size = new Dimension(width, height); driver.manage().window().setPosition(new Point(0, 0)); driver.manage().window().setSize(size); } catch (Exception ex) { } }
From source file:com.expedia.lux.accountsettingstest.core.CreateWebDriverHelper.java
License:Open Source License
public static void setBrowserSize(WebDriver driver, Integer width, Integer height) { driver.manage().window().setPosition(new Point(0, 0)); driver.manage().window().setSize(new Dimension(width, height)); }