Search code examples
adbandroidandroid-alertdialogmonkeyrunnerkey-events

Keyevent to click on Alert Dialog of Android screen


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


Solution

  • 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.