How to use touch action in Appium[Up to date: java-client 6.x.x]
Assuming we have
MobileElement myElement;
int xPoint = 282;
int yPoint = 808;
int duration = 1000; //in milliseconds, change the value as per the required
Tap on the Element with element locator(id/xpath): new TouchAction((AndroidDriver)driver).tap(tapOptions().withElement(element(myElement))).perform();
Tap on the element with Coordinates: new TouchAction((AndroidDriver)driver).tap(point(xPoint, yPoint)).perform();
Tap on the Element using coordinates relative to element: new TouchAction((AndroidDriver)driver).tap(tapOptions().withElement(element(myElement, xPoint, yPoint))).perform();
LongPress on the Element with element locator(id/xpath): new TouchAction((AndroidDriver)driver).longPress(longPressOptions().withElement(element(myElement))).release().perform();
LongPress on the Element with element locator(id/xpath) and Duration: new TouchAction((AndroidDriver)driver).longPress(longPressOptions().withElement(element(myElement)).withDuration(Duration.ofMillis(duration))).release().perform();
LongPress on the element with coordinates: new TouchAction((AndroidDriver)driver).longPress(point(xPoint, yPoint)).release().perform();
LongPress on coordinates with duration:
Note: How to find X and Y coordinate from android phone?
Comments
Post a Comment