Example usage for org.openqa.selenium Point Point

List of usage examples for org.openqa.selenium Point Point

Introduction

In this page you can find the example usage for org.openqa.selenium Point Point.

Prototype

public Point(int x, int y) 

Source Link

Usage

From source file:ru.stqa.selenium.decorated.DecoratedWindowTest.java

License:Apache License

@Test
void testSetPosition() {
    verifyFunction($ -> $.setPosition(new Point(10, 20)));
}

From source file:ru.stqa.selenium.decorated.DecoratedWindowTest.java

License:Apache License

@Test
void testGetPosition() {
    verifyFunction(WebDriver.Window::getPosition, new Point(10, 20));
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForWebElementGetLocation() {
    Fixture fixture = new Fixture();

    final WebElement mockedElement = mock(WebElement.class);
    final Point location = new Point(10, 20);

    when(fixture.mockedDriver.findElement(By.id("id"))).thenReturn(mockedElement);
    when(mockedElement.getLocation()).thenReturn(location);

    assertSame(fixture.driver.findElement(By.id("id")).getLocation(), location);

    verify(fixture.mockedDriver, times(1)).findElement(By.id("id"));
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(fixture.listener, times(1)).beforeFindElement(fixture.mockedDriver, By.id("id"));
    verify(fixture.listener, times(1)).afterFindElement(mockedElement, fixture.mockedDriver, By.id("id"));
    verify(mockedElement, times(1)).getLocation();
    verifyNoMoreInteractions(mockedElement);
    verify(fixture.listener, times(1)).beforeGetLocation(mockedElement);
    verify(fixture.listener, times(1)).afterGetLocation(location, mockedElement);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForWindowGetPosition() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    final WebDriver.Window window = mock(WebDriver.Window.class);
    final Point position = new Point(10, 20);

    when(fixture.mockedDriver.manage()).thenReturn(options);
    when(options.window()).thenReturn(window);
    when(window.getPosition()).thenReturn(position);

    assertEquals(fixture.driver.manage().window().getPosition(), position);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).window();/*from   w  w  w.j a v a  2 s  .co m*/
    verifyNoMoreInteractions(options);
    verify(window, times(1)).getPosition();
    verifyNoMoreInteractions(window);
    verify(fixture.listener, times(1)).beforeGetPosition(window);
    verify(fixture.listener, times(1)).afterGetPosition(position, window);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:ru.stqa.selenium.decorated.events.WebDriverListenerTest.java

License:Apache License

@Test
void canFireEventForWindowSetPosition() {
    Fixture fixture = new Fixture();

    final WebDriver.Options options = mock(WebDriver.Options.class);
    final WebDriver.Window window = mock(WebDriver.Window.class);
    final Point position = new Point(10, 20);

    when(fixture.mockedDriver.manage()).thenReturn(options);
    when(options.window()).thenReturn(window);

    fixture.driver.manage().window().setPosition(position);

    verify(fixture.mockedDriver, times(1)).manage();
    verifyNoMoreInteractions(fixture.mockedDriver);
    verify(options, times(1)).window();//ww w  .j  a  v  a 2 s . co  m
    verifyNoMoreInteractions(options);
    verify(window, times(1)).setPosition(position);
    verifyNoMoreInteractions(window);
    verify(fixture.listener, times(1)).beforeSetPosition(window, position);
    verify(fixture.listener, times(1)).afterSetPosition(window, position);
    verifyNoMoreInteractions(fixture.listener);
}

From source file:sandeep.kb.android.remote.android.AndroidWebElement.java

License:Apache License

private Point getCenterCoordinates() {
    if (!isDisplayed()) {
        throw new ElementNotVisibleException("This WebElement is not visisble and may not be clicked.");
    }/*from   w  w  w.jav  a2 s  .co  m*/
    driver.setEditAreaHasFocus(false);
    Point topLeft = getLocation();
    String sizeJs = "var __webdriver_w = 0;" + "var __webdriver_h = 0;"
            + "if (arguments[0].getClientRects && arguments[0].getClientRects()[0]) {"
            + "  __webdriver_w = arguments[0].getClientRects()[0].width;"
            + "  __webdriver_h = arguments[0].getClientRects()[0].height;" + " } else {"
            + "  __webdriver_w = arguments[0].offsetWidth;" + "  __webdriver_h = arguments[0].offsetHeight;"
            + "}; return __webdriver_w + ',' + __webdriver_h;";
    String[] result = ((String) driver.executeScript(sizeJs, this)).split(",");
    return new Point(topLeft.x + Integer.parseInt(result[0]) / 2, topLeft.y + Integer.parseInt(result[1]) / 2);
}

From source file:sandeep.kb.android.remote.android.AndroidWebElement.java

License:Apache License

/**
 * Where on the page is the top left-hand corner of the rendered element? it's part of
 * RenderedWebElement/*from   ww w.j  av a  2  s.com*/
 *
 * @return A point, containing the location of the top left-hand corner of the element
 */
public Point getLocation() {
    Map<String, Long> map = (Map<String, Long>) driver
            .executeAtom(AndroidAtoms.GET_TOP_LEFT_COORDINATES.getValue(), this);
    return new Point(map.get("x").intValue(), map.get("y").intValue());
}

From source file:sandeep.kb.android.remote.android.AndroidWebElement.java

License:Apache License

public Coordinates getCoordinates() {
    if (coordinates == null) {
        coordinates = new AndroidCoordinates(elementId,
                elementId.equals("0") ? new Point(0, 0) : getCenterCoordinates());
    }// ww  w .j  a  va  2s.  com
    return coordinates;
}

From source file:snapshot.webdriver.WebDriverHelper.java

License:Open Source License

/**
 * Starts a WebDriver with Screen Dimensions
 *
 * @param driver/*from w ww. j  av a 2 s . co  m*/
 * @param url
 * @param size
 * @return
 */
public static WebDriver setupDriver(WebDriver driver, String url, WindowSize size) {
    driver.manage().window().setPosition(new Point(0, 0));
    driver.manage().window().setSize(new Dimension(size.getWidth().intValue(), size.getHeight().intValue()));
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get(url);
    return driver;
}

From source file:swift.selenium.WebHelper.java

License:Open Source License

/**
 * This function saves screenshot with message embossed in the screenshot
 * @param testCaseId/*w  ww .  j av  a  2s.  c o m*/
 * @param transactionType
 * @param Message
 * @param verficationResult
 * @return
 * @throws IOException
 */
public static String saveScreenShot(Reporter report, String ssColumnName) throws IOException {
    byte[] b;
    TransactionMapping.report.strTestcaseId = report.strTestcaseId;
    TransactionMapping.report.strTrasactionType = report.strTrasactionType;
    ErrorMsg = ssColumnName;
    saveScreenShot();
    ErrorMsg = "";
    VerificationScreen = TransactionMapping.report.strScreenshot;
    // Add Text to Image
    String path = VerificationScreen.substring(7);
    if (report.strStatus.equalsIgnoreCase("Pass"))
        b = mergeImageAndText(path, ssColumnName, new Point(200, 200));
    else
        b = mergeImageAndText(path, report.strActualValue, new Point(200, 200));
    FileOutputStream fos = new FileOutputStream(path);
    fos.write(b);
    fos.close();
    return VerificationScreen;
}