Appium & Java : how to perform fast click actions?


#1

Hi All,
I would like to perform 10 quick clicks action on a button in an Android app (prefer 0.5s), but following 10 clicks’ gap is too long (approx 1.5 sec gap). Wondering what is the proper way to shorten the gap between each click in Appium Java?
I’ve tried findElement by xpath, but still no luck, wondering if there’s any other way? or it’s just simply the limitation of Appium for now? (btw i’m using io.appium 6.0.0-BETA4)
THANK YOU in advance!

MobileElement element = driver.findElement(By.id(“btnA”));
for(int i=1; i<11; i++) {
element.click();
}


#2

Why do you want to do 10 taps in quick succession ? Is this valid user story at all ?

Till date didn’t come across any app which needs such actions :grinning:


#3

Thanks for your reply, it’s a valid user story for my case, and it would be great if anyone could give me some idea how to do it. THANK YOU!


#4

@yitelu last time i needed similar i used following approach.

  • tap by element IS slow thus use tap by X, Y!
  1. find element
  2. get is center x,y
  3. now tap 10 times using x,y - it is times faster then by element (which involves element search first)

#5

Hi @Aleksei ,
Thanks for your reply. it seems that TouchAction tap is deprecated, wondering if you know other method? or wondering if you could share how to implement it?
THANK YOU

here’s my code attempts:

WebElement webElement = driver.findElement(By.xpath("//android.widget.TextView[@index=‘1’]"));
int startX=webElement.getLocation().getX();
int startY=webElement.getLocation().getY();

 TouchAction action = new TouchAction(driver);

 for(int i=1; i<11; i++){
             action.tap(startX, startY);
 }

#6

@yitelu check -> https://github.com/appium/java-client/blob/master/docs/Touch-actions.md

and look at MultiTouchAction!


#7

Awesome! that’s exactly what i needed! thanks