Using ADB to access a particular UI control on the screen

后端 未结 5 1125
时光说笑
时光说笑 2021-02-01 07:12

Is it possible for adb shell console to access an Android app\'s specific button using its id? or text?

I\'m trying to automate the button click on the dev

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 08:17

    You won't be able to use the button id, but you can get the button coordinates and simulate a tap event.

    Android comes with an input command-line tool that can simulate miscellaneous input events. To simulate tapping, use:

    input tap x y
    

    You can use the adb shell to run the command remotely:

    adb shell input tap x y
    

    Other options are:

    shell@m0:/ $ input
    input
    usage: input ...
           input text 
           input keyevent 
           input [touchscreen|touchpad|touchnavigation] tap  
           input [touchscreen|touchpad|touchnavigation] swipe     [duration(ms)]
           input trackball press
           input trackball roll  
    

提交回复
热议问题