Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tap and hold (Long press) using appium for Android?

Tags:

appium

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 not getting any solution

like image 813
krishna chetan Avatar asked Mar 27 '15 10:03

krishna chetan


People also ask

Which function is used for long press in Android in Appium?

longPress(driver. findElement(pressRecBtn)). waitAction(timeInMs). perform();

How do you tap action in Appium?

Press by using x,y coordinates, and duration (in seconds) Horizontal swipe by using the start and end percentage of the screen and an anchor for the height. Vertical swipe by using the start and end percentage of the screen and an anchor for the width. Swipe one element to another element.

How do you wait for an element in Appium?

WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait. until(ExpectedConditions. elementToBeClickable(By.id(>someid>))); To wait for the page to load to set the amount of time to wait for a page load to complete before throwing an error.


2 Answers

Need to pass driver

TouchAction action = new TouchAction(driver);
action.longPress(webElement).release().perform();
like image 93
suraj naik Avatar answered Sep 22 '22 03:09

suraj naik


Yes, you can use TouchAction class to longPress any element. Try this:

TouchAction action = new TouchAction();
action.longPress(webElement).release().perform();
like image 20
Gaurav Avatar answered Sep 22 '22 03:09

Gaurav