Let's automate a simple yet robust UI test using Maestro: open-source framework for effortless mobile and web automation.
Google Maps UI Test Automation with Maestro - Full Tutorial
0. Setup: Install Maestro CLI
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.
1. Launch the App (with clearState)
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
2. Taps: Simple and Powerful
Tap any element by its text or ID easily:
- tapOn: Skip
- tapOn: Search here
- tapOn: San Francisco
Advanced tap actions include:
- Repeated taps: Specify repetition and delays.
- Coordinates: Tap by percentage (50%,50%) or pixel positions (100,200).
- Long press: Simply use longPressOn instead of tapOn.
For a comprehensive guide, see the TapOn documentation: https://docs.maestro.dev/api-reference/commands/tapon
3. Typing: Input Text with Ease
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
4. Swipe Precisely
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
5. Scroll Until Element Visible
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
6. Validate with Regex
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.
β Complete YAML Flow
Here's the entire YAML test reflecting our scenario:
appId: com.google.android.apps.maps
- 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]'
π§ͺ Running the Test
Simply execute:
maestro test google-maps.yaml
The CLI provides real-time feedback with a green checkmark (β ) for each successful step.
Why Maestro?
β 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 ->