我们可以在Android应用程序中使用UIAutomator吗?

Far*_*cxX 5 android android-uiautomator

我想知道我们可以在应用程序中使用UIAutomator吗?我想编写一个打开另一个应用程序的应用程序,在该应用程序EditText中编写一些文本,然后按一些按钮(例如打开hangout并在其上编写文本并发送消息)。你能建议我该怎么做吗?

我已经在网上搜索了,但我只能用UIAutomator测试我的UI,但是我不知道我可以用它编写一个android应用程序(不是jar文件)并在我的android设备上运行它来执行此操作。

All*_*air 6

这是不可能的。

UiAutomator 2.0 依赖于Instrumentation,它仅在您使用am instrument .... 常规(非测试)应用程序无权访问 Instrumentation。

基于 Shell 的 UiAutomator 与此类似。您使用adb shell uiautomator runtest ...UiAutomatorTestRunner执行测试,利用它作为 shell 用户运行的事实来执行普通应用程序无权执行的操作。

如果您使用Runtime#exec(..)才能呼叫am instrumentuiautomator runtest,该命令将无法运行作为外壳用户(它会使用你的应用程序的UID),因为它不具备必要的权限将失败。