如果在屏幕上显示,我试图在视图上执行点击(或多次点击)。我想要像这样的smth,但没有obj.isVisible()
方法。
UiObject obj = device.findObject(new UiSelector().resourceId("ru.litres.android:id/container"));
UiObject objTop = device.findObject(new UiSelector().resourceId("ru.litres.android:id/container_top"));
while (obj.isVisible())
objTop.click();
答案 0 :(得分:2)
使用obj.exists()
或obj.waitForExists(timeout)
UiObject2方式:
UiDevice device =
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
while(device.hasObject(By.res("ru.litres.android", "container"))) {
objTop.click();
}
答案 1 :(得分:0)
UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
uiDevice.wait(Until.hasObject(By.res("ru.litres.android", "container")), 3000L);
UiObject2 objTop = uiDevice.findObject(By.res("ru.litres.android", "container"));
objTop.click();