Is there any code to tap and hold on Appium? i use python , is there any command to support it ?
For double click i used click on element twice, for tap and hold i am no
Yes, you can use TouchAction class to longPress any element. Try this:
TouchAction action = new TouchAction();
action.longPress(webElement).release().perform();
Need to pass driver
TouchAction action = new TouchAction(driver);
action.longPress(webElement).release().perform();
It should be like this. The duration is calculated in milliseconds, so it need to multiply by 1000 as 1 second.
TouchAction action = new TouchAction(driver);
action.longPress(webElement,duration*1000).release().perform();
This works:
TouchActions action = new TouchActions(driver);
action.longPress(element);
action.perform();
In latest Java client versions below will work.
AndroidTouchAction touch = new AndroidTouchAction (driver);
touch.longPress(LongPressOptions.longPressOptions()
.withElement (ElementOption.element (element)))
.perform ();
System.out.println("LongPressed Tapped");
Here is the update for Java Client: 5.0.4
WebElement recBtn = driver.findElement(MobileBy.id("img_button"));
new TouchAction((MobileDriver) driver).press(recBtn).waitAction(Duration.ofMillis(10000)).release().perform();