【发布时间】:2015-08-29 20:57:43
【问题描述】:
我最近在做一个 uiautomator 项目,然后 UiObject.getFromParent 对我来说是一个错误的元素,我查看了 uiautomator 的源代码,发现答案是因为我使用的 UiSelector。
我发现 uiautomator 正在使用 Instrumentation 来获取 UI 元素的东西,就像:
getInstrumentation().getUiAutomation().getRootInActiveWindow();
我只想获得一个 AccessibilityNodeInfo 节点,就像 uiautomator 所做的那样,但 uiautomator 并没有公开这一点。
我正在尝试通过一个新类扩展 InstrumentationTestCase,getInstrumentation() 总是向我返回 null。
我找到了答案
android instrumentation test case - getinstrumentation() returning null
那需要injectInstrumentation(InstrumentationRegistry.getInstrumentation());
并告诉 InstrumentationRegistry 来自官方的 Android testing-support-lib:0.1
我已经下载了 Android Support Repository 并将 testing-support-lib-0.1-source.jar 导入到我的项目中,但我仍然看不到 InstrumentationRegistry。
有人知道我的演员阵容吗?
【问题讨论】:
标签: android ui-automation android-uiautomator android-instrumentation