Search in sources :

Example 1 with Point

use of org.openqa.selenium.Point in project ghostdriver by detro.

the class WindowSizingAndPositioningTest method manipulateWindowPosition.

@Test
public void manipulateWindowPosition() {
    WebDriver d = getDriver();
    d.get("http://www.google.com");
    assertTrue(d.manage().window().getPosition().x >= 0);
    assertTrue(d.manage().window().getPosition().y >= 0);
    d.manage().window().setPosition(new Point(0, 0));
    assertTrue(d.manage().window().getPosition().x == 0);
    assertTrue(d.manage().window().getPosition().y == 0);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Point(org.openqa.selenium.Point) Test(org.junit.Test)

Example 2 with Point

use of org.openqa.selenium.Point in project android by owncloud.

the class FileListView method pulldownToRefresh.

public void pulldownToRefresh() throws InterruptedException {
    Point listLocation = listLayout.getLocation();
    driver.swipe(listLocation.getX(), listLocation.getY(), listLocation.getX(), listLocation.getY() + 1000, 5000);
}
Also used : Point(org.openqa.selenium.Point)

Example 3 with Point

use of org.openqa.selenium.Point in project android by owncloud.

the class FileListView method pulldownToSeeNotification.

public void pulldownToSeeNotification() throws InterruptedException {
    Point listLocation = deviceScreen.getLocation();
    driver.swipe(listLocation.getX(), listLocation.getY(), listLocation.getX(), listLocation.getY() + 1000, 5000);
}
Also used : Point(org.openqa.selenium.Point)

Example 4 with Point

use of org.openqa.selenium.Point in project selenium-tests by Wikia.

the class Shooter method getBoundingClientRect.

private Object[] getBoundingClientRect(WebElement element, WebDriver driver) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    ArrayList<String> list = (ArrayList<String>) js.executeScript("var rect =  arguments[0].getBoundingClientRect();" + "return [ '' + parseInt(rect.left), '' + parseInt(rect.top), '' + parseInt(rect.width), '' + parseInt(rect.height) ]", 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 Object[] { start, size };
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) ArrayList(java.util.ArrayList) Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension)

Example 5 with Point

use of org.openqa.selenium.Point in project selenium-tests by Wikia.

the class Shooter method captureWebElement.

/**
   * Create a screenshot of passed element and save screenshot as image file in temp dir. <p> Notes:
   * Method works properly in Google Chrome only if devicePixelRatio equals 1. </p>
   *
   * @param element - WebElement you want to capture
   * @param driver  - instance of WebDriver
   * @return File path  - file's handler which was saved in given path
   */
public File captureWebElement(WebElement element, WebDriver driver) {
    Point start = element.getLocation();
    Dimension size = element.getSize();
    if (!"FF".equals(Configuration.getBrowser())) {
        Object[] rect = getBoundingClientRect(element, driver);
        start = (Point) rect[0];
        size = (Dimension) rect[1];
    }
    File image = imageEditor.cropImage(start, size, capturePage(driver));
    PageObjectLogging.logImage("Shooter", image, true);
    return image;
}
Also used : Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension) File(java.io.File)

Aggregations

Point (org.openqa.selenium.Point)11 Dimension (org.openqa.selenium.Dimension)7 File (java.io.File)4 WebDriver (org.openqa.selenium.WebDriver)2 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)1 WebElement (org.openqa.selenium.WebElement)1 Actions (org.openqa.selenium.interactions.Actions)1 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)1