0

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

Flo-se
  • 3
  • 3

2 Answers2

0

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)
cle-b
  • 109
  • 4
  • Thanks for your reply However the delay between each click is up to 1-2 sec with your method. Which is quite the same as a element.click on the loop ... – Flo-se Dec 15 '17 at 10:29
0

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

barbudito
  • 548
  • 1
  • 6
  • 16
  • Thanks you for your reply But the problem is the same,the delay between each click is up to 1-2 sec with your method. So the app doesnt see it as double/triple/... click – Flo-se Dec 15 '17 at 13:52
  • Can you try saving your X and Y coordinates, go to cmd, and type "adb shell input tap x y" and do it fast enough to see if it works? I guess it won't work, but then you will have to try my python method with Threading for each tap – barbudito Dec 15 '17 at 14:56
  • And btw... Another thing... can you try this? procId.communicate('input tap x y\ninput tap x y\ninput tap x y\ninput tap x y\ninput tap x y\ninput tap x y.....') without using any loop, just 10 times 'input tap x y' – barbudito Dec 15 '17 at 15:04
  • "adb shell input tap x y" – Flo-se Dec 18 '17 at 12:51
  • "adb shell input tap x y" This command fast enough works well, so i presume appium is just to slow ... However i have found another solution which works fine (but not really pretty) : import shlex toto = 'adb shell input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100 && input tap 100 100' subprocess.Popen(shlex.split(toto),stdin = subprocess.PIPE) (sorry for the double post) – Flo-se Dec 18 '17 at 16:39