Maestro Tool – Fast Creation of Simple Automated Tests for Mobile Applications

Photo of Krzysztof Ziółek

Krzysztof Ziółek

Updated Jul 21, 2023 • 10 min read
startup business, software developer working on computer at modern office

Recently, a new test automation tool for mobile apps was released: Maestro.

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.

Test structure for Android and iOS
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

tapOn

taps on a view on the screen

longPressOn

long presses on a view or a point

assertVisible

asserts whether an element is visible

asertNotVisible

asserts whether an element is not visible

extendedWaitUntil

waits until an element becomes visible or invisible with timeout

scroll

simple vertical scroll

swipe

specifies swipe start and end points for greater control over the swipe gesture

back

navigates a user to the previous screen (Android-only at the moment)

inputText

inputs text

eraseText

removes characters from the currently selected text field

inputRandomText

method for entering a random text input

pressKey

allows you to press a set of special keys

hideKeyboard

hides the software keyboard

clipboardPaste

pastes contents of the device's clipboard onto the currently focused input field

takeScreenshot

saves a screenshot in a PNG file

openLink

opens a link on a device

clearState

clears the application state

clearKeychain

clears the entire iOS keychain

runFlow

runs a flow from a specified file

launchApp

launches the app

repeat

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.

Photo of Krzysztof Ziółek

More posts by this author

Krzysztof Ziółek

Senior Quality Assurance Engineer at Netguru
Secure your product's success  Maintain an amazing experience that your customers can rely on Check how

We're Netguru

At Netguru we specialize in designing, building, shipping and scaling beautiful, usable products with blazing-fast efficiency.

Let's talk business