Assertions and Waiting for Elements
Use assertVisible, assertNotVisible, and waitForAnimationToEnd in Maestro YAML to verify UI state and handle loading spinners before continuing the flow.
Assertions Are the Heart of Tests
A Maestro flow without assertions only tells you the app did not crash. Assertions verify that the app shows the correct content after each action. They are the part of the test that actually checks correctness.
Maestro provides a rich set of assertion commands: checking that elements are visible, not visible, contain specific text, or are enabled/disabled. Learning to write precise, targeted assertions is what distinguishes a useful E2E test from one that only provides false confidence.
assertVisible and assertNotVisible
assertVisible checks that an element with the given text or id is currently displayed on screen. It retries for up to 5 seconds by default, making it resilient to brief loading delays.
assertNotVisible is the opposite — it verifies that an element is NOT on screen. Use this to confirm that an error message disappears after the user fixes their input, or that a loading spinner is gone after data loads.
# Verify the welcome message is visible
- assertVisible:
text: 'Welcome, Alice!'
# Verify with testID
- assertVisible:
id: 'home-screen-header'
# Verify loading spinner is gone
- assertNotVisible:
id: 'loading-spinner'
# Verify error banner is not shown initially
- assertNotVisible:
text: 'Something went wrong'All lessons in this course
- Installing Maestro and Running Your First Flow
- Assertions and Waiting for Elements
- Testing Multi-Screen User Journeys
- Maestro in CI with GitHub Actions