Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A set of UI watchers to settle common Android permission dialog and alike #547

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,20 @@ def click_callback(d: u2.Device):
d.xpath("确定").click() # 在回调中调用不会再次触发watcher

d.xpath("继续").click() # 使用d.xpath检查元素的时候,会触发watcher(目前最多触发5次)


def permission_call_func(*args, **kwargs ):
d = args[0]
for item in args[1:]:
if d(**{item[0]:item[1]}).exists:
d(**{item[0]:item[1]}).click()
return True


# 注册名为allowin的监控,当出现button1和允许的时候,text为不再提示和允许出现最多点击5次
d.watcher('allowin', 5).when("//*[@resource-id='android:id/button1']").when("允许").call(
permission_call_func, d, ('text', '不再提示'), ('text', '允许'))

```

监控操作
Expand Down
Loading