简体   繁体   中英

Appium python : multiple click

I got a quesition for you,

On my application, i would like to click multiple time (10) on a button. But the application doesn't accept the tap option, so the following code doesnt work :

         multi_click = TouchAction(self.driver)
         multi_click.tap(self.driver.find_element_by_id('logo'),0,0,8)

And the click action are too slow to be compted as multiple click if i set a "while" :

     while i < 10: 
         self.driver.find_element_by_id('logo').click()
         i+= 1
         print (i)

Have you any idea ?

Regards

Does a click on this element generate a navigation to another screen ?

If not, did you try a search the element only one time (outside your loop) ?

It will be probably faster.

logo = self.driver.find_element_by_id('logo')
while i < 10: 
    logo.click()
    i+= 1
    print (i)

Have you tried to use ADB for doing such multiclick?

This is pseudo code... Not sure 100% if will work and can't test it right now...

def sendClickByAdb(self, logo):
   x = logo.location['x']
   y = logo.location['y']
   procId = subprocess.Popen('adb shell', stdin = subprocess.PIPE)
   while i < 10:
      procId.communicate('input tap '+str(x)+' '+str(y))
      i+=1
      print(i)

And the only thing you need to know is to call that method:

self.sendClickByAdb(self.driver.find_element_by_id('logo'))

I hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM