Example usage for org.openqa.selenium Point getY

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

Introduction

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

Prototype

public int getY() 

Source Link

Usage

From source file:com.mycompany.browserManipulationUtilities.BrowserScrollUtilityTest.java

/**
 * Test of executeScroll method, of class BrowserScrollUtility.
 *//*from www . j av a  2s .  co  m*/
@Test
public void testVerticalScrolling() {
    System.out.println("executeScroll");
    browser.get("https://news.ycombinator.com/news");
    int pixelsToScrollHorizontally = 0;
    int pixelsToScrollVertically = 50;
    BrowserScrollUtility.executeScroll(browser, pixelsToScrollHorizontally, pixelsToScrollVertically);
    Point topLeft = ScreenShotUtility.getViewPortTopLeftCorner(browser);
    Assert.assertTrue(topLeft.getY() == pixelsToScrollVertically);
}

From source file:com.mycompany.browserManipulationUtilities.ScreenShotUtility.java

/**
 * Captures the image of the element/*from  ww  w  .j a  v  a 2 s.c o  m*/
 * @param browser
 * @param element
 * @return
 * @throws IOException 
 */
public static BufferedImage getScreenShotOfElement(WebDriver browser, WebElement element) throws IOException {
    BufferedImage fullScreenCapture = takeScreenShot(browser);
    //get location and dimensions of target element
    Point topLeft = element.getLocation();
    Dimension elementDims = element.getSize();

    //crop out the desired part of the image
    BufferedImage elementImage = fullScreenCapture.getSubimage(topLeft.getX(), topLeft.getY(),
            elementDims.getWidth(), elementDims.getHeight());
    return elementImage;
}

From source file:com.mycompany.firstmavenproject.MouseMove.java

public void move(Object driverObject) throws AWTException, InterruptedException {
    Robot robot = new Robot();
    WebElement we = (WebElement) driverObject;
    Point p = we.getLocation();
    Thread.sleep(500);// w ww.j  ava2 s . com
    for (int i = 0; i < 20000; i++) {
        int x = ((p.getX() * i) / 20000) + ((1290 / 2) * (20000 - i) / 20000);
        int y = (((p.getY() + 80) * i) / 20000) + ((1040 / 2) * (20000 - i) / 20000);
        robot.mouseMove(x, y);
    }
    Thread.sleep(1000);
}

From source file:com.nabla.project.fronter.selenium.tests.helper.WebElementExtender.java

License:Open Source License

public static File captureElementBitmap(final WebElement element) throws IOException {
    final WrapsDriver wrapsDriver = (WrapsDriver) element;

    final File screen = ((TakesScreenshot) wrapsDriver.getWrappedDriver()).getScreenshotAs(OutputType.FILE);

    final BufferedImage img = ImageIO.read(screen);

    final int width = element.getSize().getWidth();
    final int height = element.getSize().getHeight();

    final Rectangle rect = new Rectangle(width, height);

    final Point p = element.getLocation();

    final BufferedImage dest = img.getSubimage(p.getX(), p.getY(), rect.width, rect.height);

    ImageIO.write(dest, "png", screen);
    return screen;
}

From source file:com.owncloud.android.test.ui.models.FileListView.java

License:Open Source License

public void pulldownToRefresh() throws InterruptedException {
    Point listLocation = listLayout.getLocation();
    driver.swipe(listLocation.getX(), listLocation.getY(), listLocation.getX(), listLocation.getY() + 1000,
            5000);//from w ww. j ava 2 s . com
}

From source file:com.owncloud.android.test.ui.models.FileListView.java

License:Open Source License

public void pulldownToSeeNotification() throws InterruptedException {
    Point listLocation = deviceScreen.getLocation();
    driver.swipe(listLocation.getX(), listLocation.getY(), listLocation.getX(), listLocation.getY() + 1000,
            5000);// w  ww.j  ava2s.  co m
}

From source file:com.pentaho.ctools.utils.ElementHelper.java

License:Apache License

/**
 * This method intends to check if two elements overlap or are contained inside each other, returns true if
 * elements don't overlap./*ww  w. ja v  a 2  s  .  co  m*/
 *
 * @param driver
 * @param element1
 * @param element2
 * @return
 */
public boolean ElementsNotOverlap(WebDriver driver, By element1, By element2) {
    this.log.debug("ElementsNotOverlap::Enter");
    this.log.debug("Locator1: " + element1.toString());
    this.log.debug("Locator2: " + element2.toString());

    WebElement elem1 = FindElement(driver, element1);
    WebElement elem2 = FindElement(driver, element2);

    // get borders of first element
    Point firstLocation = elem1.getLocation();
    Dimension firstDimension = elem1.getSize();
    int firstLeft = firstLocation.getX();
    int firstTop = firstLocation.getY();
    int firstRight = firstLeft + firstDimension.getWidth();
    int firstBottom = firstTop + firstDimension.getHeight();
    // get borders of second element
    Point secondLocation = elem2.getLocation();
    Dimension secondDimension = elem2.getSize();
    int secondLeft = secondLocation.getX();
    int secondTop = secondLocation.getY();
    int secondRight = secondLeft + secondDimension.getWidth();
    int secondBottom = secondTop + secondDimension.getHeight();
    this.log.debug(firstTop + " " + firstBottom + " " + firstLeft + " " + firstRight);
    this.log.debug(secondTop + " " + secondBottom + " " + secondLeft + " " + secondRight);
    // if firstElement is either to the left, the right, above or below the second return true
    boolean notIntersected = firstBottom < secondTop || firstTop > secondBottom || firstLeft > secondRight
            || firstRight < secondLeft;

    this.log.debug("ElementsNotOverlap::Exit");
    return notIntersected;
}

From source file:com.playphone.alex.ListViewXpathDemo.java

License:Apache License

public void runDemo() throws MalformedURLException {
    setupAppium();//from  w  ww.j  a v a2  s  .  c  o m
    WebDriverWait localWait = new WebDriverWait(driver, 5);
    AndroidElement myListView = (AndroidElement) localWait
            .until(ExpectedConditions.visibilityOfElementLocated(MobileBy.AccessibilityId("list view")));

    List<MobileElement> listChildren = myListView.findElementsByClassName("android.widget.TextView");
    AndroidElement firstChild = (AndroidElement) listChildren.get(0);
    System.out.println("Scrolling first element off screen");
    Point upperLeft = firstChild.getLocation();
    Dimension childSize = firstChild.getSize();
    System.out.println(
            "First child dimensions: Point(" + upperLeft.toString() + "), Dim(" + childSize.toString() + ")");
    System.out.println("First child text: " + firstChild.getText());
    int x = childSize.getWidth() / 2;

    Dimension screenSize = driver.manage().window().getSize();

    driver.swipe(x, screenSize.getHeight() - 1, x, upperLeft.getY(), 3000);

    System.out.println("Now printing the values of the first child again to see what the values are:");
    upperLeft = firstChild.getLocation();
    childSize = firstChild.getSize();
    System.out.println(
            "First child dimensions: Point(" + upperLeft.toString() + "), Dim(" + childSize.toString() + ")");
    System.out.println("First child text: " + firstChild.getText());

    cleanupAppium();
}

From source file:com.seleniumtests.uipage.htmlelements.HtmlElement.java

License:Apache License

@ReplayOnError
public void pinch() {
    PerformsTouchActions performTouchActions = checkForMobile();
    MobileElement mobElement = (MobileElement) getUnderlyingElement(element);

    // code taken from appium
    MultiTouchAction multiTouch = new MultiTouchAction(performTouchActions);

    Point upperLeft = mobElement.getLocation();
    Point center = mobElement.getCenter();
    int yOffset = center.getY() - upperLeft.getY();

    TouchAction<?> action0 = createTouchAction()
            .press(ElementOption.element(mobElement, center.getX(), center.getY() - yOffset))
            .moveTo(ElementOption.element(mobElement)).release();
    TouchAction<?> action1 = createTouchAction()
            .press(ElementOption.element(mobElement, center.getX(), center.getY() + yOffset))
            .moveTo(ElementOption.element(mobElement)).release();

    multiTouch.add(action0).add(action1).perform();

}

From source file:com.seleniumtests.uipage.htmlelements.HtmlElement.java

License:Apache License

@ReplayOnError
public void zoom() {
    PerformsTouchActions performTouchActions = checkForMobile();
    MobileElement mobElement = (MobileElement) getUnderlyingElement(element);

    MultiTouchAction multiTouch = new MultiTouchAction(performTouchActions);

    Point upperLeft = mobElement.getLocation();
    Point center = mobElement.getCenter();
    int yOffset = center.getY() - upperLeft.getY();

    TouchAction<?> action0 = createTouchAction().press(PointOption.point(center.getX(), center.getY()))
            .moveTo(ElementOption.element(mobElement, center.getX(), center.getY() - yOffset)).release();
    TouchAction<?> action1 = createTouchAction().press(PointOption.point(center.getX(), center.getY()))
            .moveTo(ElementOption.element(mobElement, center.getX(), center.getY() + yOffset)).release();
    multiTouch.add(action0).add(action1).perform();
}