How to simulate touch events on Android device?

混江龙づ霸主 提交于 2019-12-11 09:15:18

问题


Does the Android API expose facilities for generating touch events, for example, repeatedly simulating different gestures on the screen for testing?


回答1:


Doesn adb commands will work for u or u need some kind of monkay testing tool commands ???

For adb commands u can use below shell commands...

adb shell input tap x y and also

adb shell sendevent /dev/input/event0 3 0 5 adb shell sendevent /dev/input/event0 3 1 29 adb shell sendevent /dev/input/event0 1 330 1 adb shell sendevent /dev/input/event0 0 0 0 adb shell sendevent /dev/input/event0 1 330 0 adb shell sendevent /dev/input/event0 0 0 0




回答2:


You can write an Android Instrumention Test to implement UI auto testing in android, see Tesing UI for a Single Activity and Android Testing Support Library.

If you are new to Android Test, I suggest you read Activity Testing first.



来源:https://stackoverflow.com/questions/31911110/how-to-simulate-touch-events-on-android-device

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