【问题标题】:uiautomator dump in Runtime.getRuntime().exec() not workingRuntime.getRuntime().exec() 中的 uiautomator 转储不起作用
【发布时间】:2016-05-04 00:08:50
【问题描述】:

当我将此行放入我的测试应用程序 Runtime.getRuntime().exec("uiautomator dump") 时,没有转储任何 .xml 文件。我很确定我检查了正确的位置。

我尝试通过设置断点来调试我的应用程序。当它到达断点时,我在终端上adb shell进入设备,然后从终端手动运行uiautomator dump,然后它说killed,也没有生成.xml文件。

adb shell uiautomator dump 仅在我杀死我的应用程序时生成 .xml 文件,并从终端运行此命令。

这是一种权限或可访问性问题吗?

【问题讨论】:

  • 另请参阅When Runtime.exec() won't,了解有关正确创建和处理流程的许多好技巧。然后忽略它引用exec 并使用ProcessBuilder 创建进程。确保将String arg 分解为String[] args 以说明其中包含空格的路径。

标签: android runtime.exec android-uiautomator


【解决方案1】:

您不能在测试运行时使用adb shell uiautomator dump

您可以改为从测试内部调用UiDevice.dumpWindowHierarchy(..)

【讨论】:

  • 为什么我们不能在测试运行时使用 adb shell uiautomator dump?
  • 框架有一个限制 - 一次只能连接一个 UiAutomation 客户端。当您的测试运行时,它具有连接。这会阻止uiautomator dump 连接。
  • 这真的很有帮助。谢谢解释!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多