Search in sources :

Example 6 with Rectangle

use of org.openqa.selenium.Rectangle in project carina by qaprosoft.

the class DivisionElementExtractor method checkBoundaryElements.

/**
 * Method to check boundary elements since there is a chance that there are
 * some elements in the same 'y' range
 *
 * @param elements List<WebElement>
 * @param x int
 * @param y int
 * @param index int
 * @return List<WebElement>
 */
private List<WebElement> checkBoundaryElements(List<WebElement> elements, int x, int y, int index) {
    LOGGER.debug(String.format("Index: %d.", index));
    List<WebElement> elementsFirstPart = elements.subList(0, index);
    List<WebElement> elementsSecondPart = elements.subList(index, elements.size());
    List<WebElement> elementsInside = new ArrayList<WebElement>();
    WebElement element;
    Rectangle tempRect;
    for (int i = elementsFirstPart.size() - 1; i >= 0; i--) {
        element = elementsFirstPart.get(i);
        tempRect = getRect(element);
        if (isInside(tempRect, x, y)) {
            elementsInside.add(element);
        } else if (tempRect.y > y) {
            // element's location
            break;
        }
    }
    for (int i = 0; i < elementsSecondPart.size(); i++) {
        element = elementsSecondPart.get(i);
        tempRect = getRect(element);
        if (isInside(tempRect, x, y)) {
            elementsInside.add(element);
        } else if (tempRect.y + tempRect.height < y) {
            // element's location
            break;
        }
    }
    return elementsInside;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(org.openqa.selenium.Rectangle) WebElement(org.openqa.selenium.WebElement) ExtendedWebElement(com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement)

Aggregations

Rectangle (org.openqa.selenium.Rectangle)6 WebElement (org.openqa.selenium.WebElement)4 ExtendedWebElement (com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement)3 ArrayList (java.util.ArrayList)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 WebDriver (org.openqa.selenium.WebDriver)2 TouchAction (io.appium.java_client.TouchAction)1 IOSTouchAction (io.appium.java_client.ios.IOSTouchAction)1