Keyevent to click on Alert Dialog of Android screen

∥☆過路亽.° 提交于 2020-01-12 10:19:54

问题


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


回答1:


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.




回答2:


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)


来源:https://stackoverflow.com/questions/17612315/keyevent-to-click-on-alert-dialog-of-android-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!