Поэтому в основном я хочу дождаться любого из возможных теги, которые должны быть там. Как только появится первый из них, код должен вернуть true. Я не знаю, как это сделать. Вот чем я сейчас занимаюсь:
Код: Выделить всё
fun MacrobenchmarkScope.waitForDashboardContent() {
device.wait(Until.hasObject(By.res("dashboard_feed")), 10_000)
val lazyColumn = device.findObject(By.res("dashboard_feed"))
lazyColumn.wait(Until.hasObject(By.res("dashboard_section_title")), 2_000)
}
Код: Выделить всё
lazyColumn.wait(Until.hasObject(By.any(By.res("dashboard_section_title"),By.res("another_section_title"))),2_000)
Код: Выделить всё
val lazyColumn = device.findObject(By.res("dashboard_feed"))
val startTime = System.currentTimeMillis()
val timeout = 2000
while (System.currentTimeMillis() - startTime < timeout) {
if (lazyColumn.hasObject(By.res("dashboard_section_title")) ||
lazyColumn.hasObject(By.res("another_section_title"))) {
// One of the elements was found within the timeout
break
}
// Small delay to prevent tight looping
Thread.sleep(100)
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... conditions
Мобильная версия