Let's automate a simple yet robust UI test using Maestro: open-source framework for effortless mobile and web automation.
What if we test Google Maps? How easy would that be? Check it out!
Let's automate a simple yet robust UI test using Maestro: open-source framework for effortless mobile and web automation.
First, youβll need Maestro CLI installed:
curl -fsSL https://get.maestro.mobile.dev | bash
Check the installation by running:
maestro --version
For specific versions or advanced setups, see installation docs.
Using clearState ensures the app starts without previous data (shared preferences, databases, accounts, etc.). Think of it as a fresh install every time.
- launchApp:
clearState: true
π clearState Docs: https://docs.maestro.dev/api-reference/commands/clearstate
Tap any element by its text or ID easily:
- tapOn: Skip
- tapOn: Search here
- tapOn: San Francisco
Advanced tap actions include:
For a comprehensive guide, see the TapOn documentation: https://docs.maestro.dev/api-reference/commands/tapon
Maestro inputs text into fields automatically, even if they aren't initially focused:
- inputText: san francisco
You can also generate random inputs, like emails, names, or numbers, for varied test scenarios.
π inputText Documentation: https://docs.maestro.dev/api-reference/commands/inputtext
Swipe actions are straightforward. In our test, we swipe upwards from a specific element (header) to reveal more content:
- swipe:
from:
id: 'com.google.android.apps.maps:id/header'
direction: UP
Specify swipes by direction (UP, DOWN, LEFT, RIGHT) or exact coordinates.
π Swipe Documentation: https://docs.maestro.dev/api-reference/commands/swipe
Maestro scrolls automatically until the specified element is visibleβvery handy for dynamic lists:
- scrollUntilVisible:
element: See all
direction: RIGHT
speed: 90
You can also set scrolling direction, speed, and timeout duration.
π scrollUntilVisible Documentation: https://docs.maestro.dev/api-reference/commands/scrolluntilvisible
Regex assertions ensure dynamic content like timestamps (e.g., 3:15) are correctly displayed:
- assertVisible: '[0-9]+:[0-9][0-9]'
Regex provides powerful and flexible validations for text-based elements.
Here's the entire YAML test reflecting our scenario:
- launchApp:
clearState: true
- tapOn: Skip
- tapOn: Search here
- inputText: san francisco
- tapOn: San Francisco
- swipe:
from:
id: 'com.google.android.apps.maps:id/header'
direction: UP
- scrollUntilVisible:
element: See all
direction: RIGHT
speed: 90
- tapOn: See all
- tapOn: Videos
- assertVisible: '[0-9]+:[0-9][0-9]'
Simply execute:
maestro test google-maps.yaml
The CLI provides real-time feedback with a green checkmark (β ) for each successful step.
β Declarative & readable YAML
β Cross-platform (Android, iOS, Web)
β Quick and reliable tests
β Fully open source (Apache-2.0)
We're entering a new era of software development. Advancements in AI and tooling have unlocked unprecedented speed, shifting the bottleneck from development velocity to quality control. This is why we built β a modern testing platform that ensures your team can move quickly while maintaining a high standard of quality.
Learn more ->