Example usage for org.openqa.selenium Point moveBy

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

Introduction

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

Prototype

public Point moveBy(int xOffset, int yOffset) 

Source Link

Usage

From source file:org.richfaces.fragment.common.Utils.java

License:Open Source License

/**
 * Returns Locations of input element.// w  ww  .  ja  va  2 s  .  c o m
 *
 * @see Locations
 */
public static Locations getLocations(WebElement root) {
    Preconditions.checkNotNull(root, "The element cannot be null.");
    Point topLeft = root.getLocation();
    Dimension dimension = root.getSize();
    Point topRight = topLeft.moveBy(dimension.getWidth(), 0);
    Point bottomRight = topRight.moveBy(0, dimension.getHeight());
    Point bottomLeft = topLeft.moveBy(0, dimension.getHeight());
    return new Locations(topLeft, topRight, bottomLeft, bottomRight);
}

From source file:org.richfaces.tests.page.fragments.impl.Utils.java

License:Open Source License

/**
 * Returns Locations of input element.//w  w w  .j ava  2  s.  com
 * @see Locations
 */
public static Locations getLocations(WebElement root) {
    Point topLeft = root.getLocation();
    Dimension dimension = root.getSize();
    Point topRight = topLeft.moveBy(dimension.getWidth(), 0);
    Point bottomRight = topRight.moveBy(0, dimension.getHeight());
    Point bottomLeft = topLeft.moveBy(0, dimension.getHeight());
    return new Locations(topLeft, topRight, bottomLeft, bottomRight);
}

From source file:org.safs.selenium.webdriver.lib.model.EmbeddedObject.java

License:Open Source License

/**
 * To check if an Element is visible on page.<br>
 * If the center of the element is in the container and is shown in the browser's client area, the<br>
 * element will be considered as visible on page.<br>
 * @param element Element, the element to check
 * @return boolean, true if the element is visible on page.
 * @throws SeleniumPlusException//w ww . ja v a 2  s.  c  o m
 */
protected boolean isShowOnPage(Element element) throws SeleniumPlusException {
    WDLibrary.checkNotNull(element);

    try {
        WebElement item = element.getWebElement();
        org.openqa.selenium.Dimension itemD = item.getSize();
        org.openqa.selenium.Point itemCenterOffset = new org.openqa.selenium.Point(itemD.width / 2,
                itemD.height / 2);
        org.openqa.selenium.Point itemLoc = item.getLocation();
        org.openqa.selenium.Point itemCenterLoc = itemLoc.moveBy(itemCenterOffset.x, itemCenterOffset.y);

        WebElement container = webelement();
        org.openqa.selenium.Dimension containerD = container.getSize();
        org.openqa.selenium.Point containerLoc = container.getLocation();
        org.openqa.selenium.Point itemCenterLocRelativeToContainer = itemCenterLoc.moveBy(-containerLoc.x,
                -containerLoc.y);

        if (item.isDisplayed() //the item is considered displayed by Selenium
                && WDLibrary.isLocationInBounds(itemCenterLocRelativeToContainer, containerD) //the center of item is shown in the container
                && WDLibrary.isShowOnPage(item, itemCenterOffset) //the center of the item is shown in browser
        ) {
            return true;
        }
    } catch (Exception e) {
        IndependantLog.error(StringUtils.debugmsg(false) + "Met " + StringUtils.debugmsg(e));
    }

    return false;
}