Keyevent to click on Alert Dialog of Android scree

2019-03-31 05:16发布

Is there any way to simulate keyevent on "OK" or "CANCEL" buttons of Android dialogue box using adb commands?

2条回答
干净又极端
2楼-- · 2019-03-31 05:51

One indirect way is:-

adb shell uiautomator dump /data/view.xml
adb shell cat /data/view.xml

calculate OK button coordinates from the relative coordinates given in the xml file. Then do

adb shell input tap <x> <y>

Hope works.

查看更多
The star\"
3楼-- · 2019-03-31 06:14

Using AndroidViewClient/culebra you can simply do:

  1. run java -jar androidviewclient-2.3.25.jar culebra --verbose --verbose-comments --find-views-with-text=true --output=myscript.py
  2. edit myscript.py and add vc.findViewWithTextOrRaise('Cancel').touch() at the end (you can delete the unnecessary finds too)
查看更多
登录 后发表回答