Is there any way to simulate keyevent on "OK" or "CANCEL" buttons of Android dialogue box using adb commands?
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.
Using AndroidViewClient/culebra you can simply do:
- run
java -jar androidviewclient-2.3.25.jar culebra --verbose --verbose-comments --find-views-with-text=true --output=myscript.py
- edit
myscript.py
and addvc.findViewWithTextOrRaise('Cancel').touch()
at the end (you can delete the unnecessary finds too)
来源:https://stackoverflow.com/questions/17612315/keyevent-to-click-on-alert-dialog-of-android-screen