Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Request for new functionality
View staffing
Description
Sometimes, an instrumented test needs to wait until a UI element appears on the screen, or more generally, until the UI matches a certain condition.
When the UI will reach that state purely due to progression controlled by the test (e.g. injecting input, animations, compositions, etc), then simply calling
waitForIdle()
will fast-forward the app's clock until it is idle, at which point the UI will be in said state.However, when the UI will reach that state due to external changes that are not tracked by compose,
waitForIdle()
will not be aware that there are still things to wait for and will return too early. For this use case, we havewaitUntil(condition: () -> Boolean)
, where the condition can check if the external state has reached the desired state yet.However, when the condition needs to check elements on the UI, one needs to call
onNode(<matcher>).assertExists()
and catch-repeat until it doesn't throw anymore. That use case should be supported directly to avoid the need for this pattern.