Skip to content

Commit

Permalink
Add wait when getting object
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbileck committed Jan 7, 2025
1 parent 7fd80b7 commit 79ec6e3
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ class NotificationTest {

val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
device.openNotification()
device.wait(Until.hasObject(By.text("Bisq")), WAIT_CONDITION_TIMEOUT_MS)
bisqNotifications.forEach { bisqNotification ->
device.wait(Until.hasObject(By.text("Bisq")), WAIT_CONDITION_TIMEOUT_MS)
val title: UiObject2 = device.getObject(By.text(bisqNotification.title!!))
val text: UiObject2 = device.getObject(By.text(bisqNotification.message!!))
assertThat(title.text).isEqualTo(bisqNotification.title)
Expand Down Expand Up @@ -184,6 +184,8 @@ class NotificationTest {
).build()
}

private fun UiDevice.getObject(selector: BySelector): UiObject2 =
findObject(selector) ?: error("Object not found for: $selector")
private fun UiDevice.getObject(selector: BySelector): UiObject2 {
wait(Until.hasObject(selector), WAIT_CONDITION_TIMEOUT_MS)
return findObject(selector) ?: error("Object not found for: $selector")
}
}

0 comments on commit 79ec6e3

Please sign in to comment.