use of io.appium.java_client.TouchAction in project opentest by mcdcorp.
the class Tap method run.
@Override
public void run() {
super.run();
By locator = this.readLocatorArgument("locator", null);
Integer xOffset = this.readIntArgument("xOffset", null);
Integer yOffset = this.readIntArgument("yOffset", null);
Integer x = this.readIntArgument("x", null);
Integer y = this.readIntArgument("y", null);
if (locator != null) {
this.swipeAndCheckElementVisible(locator, this.getSwipeOptions());
MobileElement element = this.getElement(locator);
if (xOffset == null || yOffset == null) {
element.click();
} else {
(new TouchAction(driver)).tap(TapOptions.tapOptions().withElement(ElementOption.element(element, xOffset != null ? xOffset : 0, yOffset != null ? yOffset : 0))).perform();
}
} else if (x != null && y != null) {
(new TouchAction(driver)).tap(TapOptions.tapOptions().withPosition(PointOption.point(x, y))).perform();
} else {
throw new RuntimeException("You must either provide the locator argument of the element to tap, " + "or the x and y arguments to indicate the exact coordinates to tap at.");
}
}
Aggregations