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;
}
Aggregations