can we use UIAutomator in android applications?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 11:11:14

This isn't possible.

UiAutomator 2.0 relies on Instrumentation which is only available when you run your test using am instrument .... Regular (non-test) apps don't have access to Instrumentation.

Shell-based UiAutomator is similar. You execute tests using adb shell uiautomator runtest ... and UiAutomatorTestRunner takes advantage of the fact that it is running as the shell user to do things that normal apps don't have permission to do.

If you use Runtime#exec(..) to call either am instrument or uiautomator runtest, the command won't run as the shell user (it will use your application's uid), and will fail because it doesn't have the necessary permissions.

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