How to use touch action in new java client 6.0.0-BETA4

having:

MobileElement myElement;
int xPoint, int yPoint;
int duration = XXXX; //in miliseconds

Tap on Element:

new TouchAction(localdriver).tap(tapOptions().withElement(element(myElement))).perform();

Tap on Coordinates:

new TouchAction(localdriver).tap(point(xPoint, yPoint)).perform();

Tap on Element using coordinates relative to element:

new TouchAction(localdriver).tap(tapOptions().withElement(element(myElement, xPoint, yPoint))).perform();

LongPress on Element:

new TouchAction(localdriver).longPress(longPressOptions().withElement(element(myElement))).release().perform();

LongPress on Element with Duration:

new TouchAction(localdriver).longPress(longPressOptions().withElement(element(myElement)).withDuration(Duration.ofMillis(duration))).release().perform();

LongPress on coordinates:

new TouchAction(localdriver).longPress(point(xPoint, yPoint)).release().perform();

And so on…

4 Likes