简体   繁体   English

Appium python:多次单击

[英]Appium python : multiple click

I got a quesition for you, 我为你请教

On my application, i would like to click multiple time (10) on a button. 在我的应用程序上,我想在一个按钮上单击多次(10)。 But the application doesn't accept the tap option, so the following code doesnt work : 但是应用程序不接受tap选项,因此以下代码不起作用:

         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”,则单击动作太慢而无法被计算为多次单击:

     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? 您是否尝试过使用ADB进行这种多点击?

This is pseudo code... Not sure 100% if will work and can't test it right now... 这是伪代码...不确定100%是否能正常工作并且现在无法对其进行测试...

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 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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