openatx / uiautomator2

Android Uiautomator2 Python Wrapper
MIT License
6.66k stars 1.41k forks source link

设置了watcher,使用xpath进行点击,找不到元素时,不会触发watcher #420

Open renguoliang opened 5 years ago

renguoliang commented 5 years ago
baolitoumu commented 5 years ago

没人啊,我试了也不行。。

codeskyblue commented 5 years ago

请提供测试代码

                            命令行

                                邮箱:codeskyblue@gmail.com

    签名由 网易邮箱大师 定制

在2019年09月19日 16:14,tao 写道: 没人啊,我试了也不行。。

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/openatx/uiautomator2/issues/420?email_source=notifications\u0026email_token=AAZBGGIH6JJN53DDDVRRLJLQKMYFPA5CNFSM4IOQSU22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7CT7LI#issuecomment-533020589", "url": "https://github.com/openatx/uiautomator2/issues/420?email_source=notifications\u0026email_token=AAZBGGIH6JJN53DDDVRRLJLQKMYFPA5CNFSM4IOQSU22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7CT7LI#issuecomment-533020589", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

baolitoumu commented 5 years ago

import uiautomator2 as u2 d = u2.connect("ce10171a3a96042f0c7e") d.watcher("查看规则").when(text="查看规则").press("back") print(d.watchers) d.xpath('//*[@resource-id="com.lianjia.alliance.plugin:id/qr_icon"]').click()

跟他的代码一样,执行之后没有任何反应,也不报错,打印atx-agent.log 也未见到报错,简单说就是执行 d.watcher("查看规则").when(text="查看规则").press("back") 后,如果元素存在,则会触发press,如果没有,则不会起到watcher的作用,d.watchers.run(),不会起到watcher的作用

codeskyblue commented 5 years ago

推荐使用d.xpath.when

Sent with GitHawk