How to long press on android record button(during chat) for a particular time duration in appium test, by java. I have tried 3 ways but all are not working, those are:

Way 1:

By pressRecBtn = By.id("recorderButton");
int x = 353;  // x coordinate of device screen, get it after enabling the Show touch and Pointer location from developer option 
int y = 980; // same as x
int timeInMs = 4000;

Action.longPress(driver.findElement(pressRecBtn)).longPress(x, y, timeInMs).perform();

Way 2:

By pressRecBtn = By.id("recorderButton");
int timeInMs = 4000;


for this way it's pressed on record button but for a default time(>=1000 MS).

Way 3:

By pressRecBtn = By.id("recorderButton");


This way also working same as way 2.

1 Answer 1


Its working cool!!

By tapOnRecIcon = By.id("btnRecord");    
int timeInMs = 4000;
TouchAction touchAction = new TouchAction((MobileDriver) driver);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.