use of org.openqa.selenium.Rectangle in project page-factory-2 by sbtqa.
the class MobileStepsImpl method press.
/**
* User make touch action tap on the element's center
*
* @param elementTitle title of the element
*/
public T press(String elementTitle) throws PageException {
WebElement element = Environment.getFindUtils().getElementByTitle(PageContext.getCurrentPage(), elementTitle);
Rectangle rect = element.getRect();
int centerX = rect.getX() + rect.getWidth() / 2;
int centerY = rect.getY() + rect.getHeight() / 2;
TouchAction touchAction = new TouchAction(Environment.getDriverService().getDriver());
touchAction.tap(PointOption.point(centerX, centerY)).perform();
return (T) this;
}
use of org.openqa.selenium.Rectangle in project selenium_java by sergueik.
the class BaseTest method highlightNew.
protected void highlightNew(WebElement element, long highlightInterval) {
Rectangle elementRect = element.getRect();
String highlightScript = getScriptContent("highlight.js");
try {
wait.until(ExpectedConditions.visibilityOf(element));
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver).executeScript(String.format("%s\nhighlight_create(arguments[0],arguments[1],arguments[2],arguments[3]);", highlightScript), elementRect.y, elementRect.x, elementRect.width, elementRect.height);
}
Thread.sleep(highlightInterval);
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver).executeScript(String.format("%s\nhighlight_remove();", highlightScript));
}
} catch (InterruptedException e) {
// System.err.println("Ignored: " + e.toString());
}
}
use of org.openqa.selenium.Rectangle in project carina by qaprosoft.
the class DivisionElementExtractor method getElementsByCoordinates.
@Override
public ExtendedWebElement getElementsByCoordinates(int x, int y) {
String elementName = String.format("Element founded by x:%d - y:%d", x, y);
WebDriver driver = getDriver();
List<WebElement> elements = getEndLevelElements(driver);
WebElement tempElement;
int index = 0;
int isLower;
Rectangle tempRect;
while (elements.size() != 1) {
index = (int) (Math.round(elements.size() / 2f));
tempElement = elements.get(index);
tempRect = getRect(tempElement);
isLower = isLower(tempRect, y);
LOGGER.debug("Is Lower: " + isLower);
if (isInside(tempRect, x, y) || isLower == 0) {
break;
}
if (isLower == 1) {
elements = elements.subList(index, elements.size());
} else {
elements = elements.subList(0, index);
}
}
LOGGER.debug("Index: " + index);
if (elements.size() == 1) {
return generateExtenedElement(elements, elementName);
}
return generateExtenedElement(checkBoundaryElements(elements, x, y, index), elementName);
}
use of org.openqa.selenium.Rectangle in project selenium_java by sergueik.
the class Select2WrapperTest method highlightNew.
private void highlightNew(WebElement element, long highlight_interval) {
Rectangle elementRect = element.getRect();
String highlightScript = getScriptContent("highlight.js");
try {
wait.until(ExpectedConditions.visibilityOf(element));
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver).executeScript(String.format("%s\nhighlight_create(arguments[0],arguments[1],arguments[2],arguments[3]);", highlightScript), elementRect.y, elementRect.x, elementRect.width, elementRect.height);
}
Thread.sleep(highlight_interval);
if (driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver).executeScript(String.format("%s\nhighlight_remove();", highlightScript));
}
} catch (InterruptedException e) {
// System.err.println("Ignored: " + e.toString());
}
}
use of org.openqa.selenium.Rectangle in project carina by qaprosoft.
the class ScreenElementExtractor method getElementsByCoordinates.
@Override
public ExtendedWebElement getElementsByCoordinates(int x, int y) {
String elementName = String.format("Element founded by x:%d - y:%d", x, y);
WebDriver driver = getDriver();
List<WebElement> elements = getEndLevelElements(driver);
List<WebElement> result = new ArrayList<WebElement>();
Rectangle rect;
for (WebElement webElement : elements) {
try {
rect = getRect(webElement);
} catch (Exception e) {
continue;
}
if (isInside(rect, x, y)) {
result.add(webElement);
}
}
return generateExtenedElement(result, elementName);
}
Aggregations