0
我想使用UiAutomator来单击系统弹出窗口的按钮。所以我在MainActivity类的一个functin中添加了下面的代码。UiDevice.getInstance失败,出现异常
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
device.wait(Until.hasObject(By.pkg("com.android.systemui").depth(0)), 2000);
try {
device.findObject(new UiSelector().textContains("START").className("android.widget.Button")).click();
}
catch (UiObjectNotFoundException e){
e.printStackTrace();
}
但在运行应用程序时,控制台报:
没有仪器注册!在android.support.test.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)下注册 仪表 必须运行
哪一部分需要修正?我是仪器新手。谢谢。