【问题标题】:How to get an instance of android.app.UiAutomation如何获取 android.app.UiAutomation 的实例
【发布时间】:2015-01-19 21:21:32
【问题描述】:

我正在测试Android 5.0 的一些新功能,现在是轮到UiAutomator 和实现的新方法。我尝试搜索示例/指南,然后尝试通过

获取 UiAutomator 的实例
getSystemService()

但这没有帮助。我的目标是使用executeShellCommands(String str)

有人已经实现了吗?

【问题讨论】:

  • 您能否重新表述您的问题,以便清楚地了解您正在寻找什么?
  • 是的,当然.. 指责我的短语形式不正确..

标签: android ui-automation android-5.0-lollipop android-uiautomator


【解决方案1】:

澄清一下,UiAutomation 类不是 UiAutomator 的一部分(尽管它们的名称相似)。

您可以通过调用获取 UiAutomation 实例 Instrumentation#getUiAutomation()。这仅在您运行基于 Instrumentation 的测试时才有效。

如果这是基于 shell 的 UiAutomator 测试的一部分,那么您可以使用 Runtime#exec() 执行 shell 命令。

【讨论】:

    猜你喜欢
    • 2019-07-08
    • 1970-01-01
    • 2023-03-03
    • 2012-10-11
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多