Maestro Tool – Fast Creation of Simple Automated Tests for Mobile Applications
This tool is positioned as the easiest way to automate UI tests for your mobile app. It’s hard to disagree with this claim because learning how to use it took me several dozen minutes.
The documentation is concise and offers clear examples, so it’s easy to follow.
On top of that, you don't need to know mobile application coding languages to write automated tests using the Maestro tool. It’s enough to have the binary file of the application for the given platform.
Will Maestro revolutionize mobile application testing? In the following article, I will present the Maestro tool and outline my thoughts on using it.
What is Maestro?
The Maestro tool is an open-source mobile testing framework that's compatible with both Android and iOS. Super simple and intuitive, it reduces the time to build a functioning automated UI test by more than 10 times. Additionally, updating tests is just as easy.
Source: mobile-dev-inc/maestro, Github
You can create a flow for any app on Android and iOS, with just a few lines of YAML.
Source: mobile-dev-inc/maestro, Github
At the time of writing this article, it’s possible to run automated tests on real Android devices and emulators, as well as automated tests on iOS simulators. Support for the latest iOS 16 and real iOS devices is still missing.
Development of the Maestro tool is constantly ongoing, so the information described here may change over time.
Why use the Maestro tool?
The creators claim the Maestro tool is built on learnings from its predecessors (Appium, Espresso, UI Automator, XCTest), and has several advantages:
- Built-in tolerance to flakiness. With mobile apps and devices, there’s often instability. That stems from UI elements not necessarily being where you expect them to be and tapping the screen not always working. Maestro embraces that instability and tries to counter it.
- Built-in tolerance to delays. With the Maestro tool, there’s no need to intersperse tests with
sleep()
calls. Why? Because Maestro knows it might take time to load content over the network and automatically waits. - Lightning fast iteration. Since tests are interpreted, there’s no need to compile code each time. The Maestro tool continuously monitors test files and reruns them automatically as they change.
- Declarative yet robust syntax. With Maestro, you define tests in a human-readable yaml file, where the syntax is clear and uncomplicated.
- Simple setup. Maestro is a single binary tool that works anywhere, including macOS, Linux, and Windows.
- Cross-platform. The Maestro tool runs automated tests on iOS and Android. It also supports ReactNative, Flutter, WebViews, and pure Native apps.
- Quick learning of the tool. Maestro has concise and clear documentation with examples, supporting new users.
- Ability to run tests on continuous integration (CI). Simple configuration with CI tools.
- Access to the application code isn’t required. You only need an APK or APP file.
Main commands when using the Maestro tool
Commands |
Description |
|
taps on a view on the screen |
|
long presses on a view or a point |
|
asserts whether an element is visible |
|
asserts whether an element is not visible |
|
waits until an element becomes visible or invisible with timeout |
|
simple vertical scroll |
|
specifies swipe start and end points for greater control over the swipe gesture |
|
navigates a user to the previous screen (Android-only at the moment) |
|
inputs text |
|
removes characters from the currently selected text field |
|
method for entering a random text input |
|
allows you to press a set of special keys |
|
hides the software keyboard |
|
pastes contents of the device's clipboard onto the currently focused input field |
|
saves a screenshot in a PNG file |
|
opens a link on a device |
|
clears the application state |
|
clears the entire iOS keychain |
|
runs a flow from a specified file |
|
launches the app |
|
repeats set of commands N times |
Other features:
- hierarchy – command prints out the whole view hierarchy that’s currently being shown
- variables – you can pass parameters to the Maestro tool via CLI and then refer to them in your flow using
${text}
notation - conditions – you can run a subflow by adding a condition to it
Limitations and disadvantages
- It’s not possible to write complicated tests
- You can’t set variables in the test script
- There’s only a small community at the moment
- Test execution isn’t as fast as other frameworks like Appium, XCUITeset, and Espresso
- No detailed reports are created
- Real iOS devices aren’t supported yet
- You can't run shell scripts inside the flow
What is the Maestro tool for?
Maestro is suitable for creating simple tests quickly for the most important functions of your mobile application. For example, you can run automated UI tests every day on CI and receive a morning report.
The tool isn’t perfect, but development is still ongoing. Just at the time of writing this, the latest version of the Maestro tool – 1.10.1 – was released. What’s more, the issues tab in the Maestro repo displays reports that introduce new features or fix bugs, giving hope that in the future, this framework will get better and better.