close up photo of smartphone

Mobile Apps UI Testing using the Maestro Framework

Instagram mobile app LG smartphone
UI Testing Automation for Mobile Apps

Maestro provides an easy to use and highly human readable framework to Automate UI testing for both the Android and iOS mobile platforms.

Read further to learn how

Mobile apps UI testing automation has always been a daunting task. It involves setting up the framework, connecting it to the physical or emulated devices and then writing tests, which has had many moving parts. When thinking of frameworks which enable us to achieve this, some of the names that come to mind are Selendroid, Appium, Espresso, EarlGrey, Robotium, etc. There are many more, but most of them use one or the other of the priors under the hood. A more recent entrant in the scenario is the Maestro framework by mobile.dev

Introduction to Maestro

This is a framework that takes the simplicity of human readable syntax in YAML and fuses it over the learning from the predecessors like Appium, XCUIT, etc. This results in reliable tests which are written in syntax close to natural language, making it easy for anyone to write mobile UI automation tests without a lot of onboarding. The framework abstracts away most of the setup and practically works right out of the box with either an emulated or a physical device.

Added benefits of using the Maestro framework are that it largely removes away the flakiness of tests by employing smart techniques to identify the elements and the interactions to perform on them. It also incorporates delays to let the UI elements settle, thus not needing explicit sleep statements. Those address most of the pain points that one faces while automating mobile UI testing. Add to that the extended support to mobile apps on both the iOS and the Android platforms as well as the Flutter and ReactNative apps, Maestro becomes a great choice for adoption.

Setting up the Maestro framework

Setting up the Maestro framework is a cake walk. All you have to do is install the binary on your system.

To install it on any Linux based shell

On MacOS, the Xcode Command Line Tools are a prerequisite. You could either install it from
Xcode -> Preferences -> Locations -> Command Line Tools.
Running the maestro framework without this would still bring up the prompt to install these if you do not have them installed. So you could skip this step now, but have to install them anyway on your first run.

And that’s it! You can move on to writing and running your tests.


To install it on Windows, you would install it on the Windows Subsystem for Linux (WSL2) using the above command, but there are some additional pre-requisites that should be fulfilled here.

  1. You should have PowerShell installed on your system. Usually it comes pre-installed in standard Windows installations for windows 10 and onwards
  2. Android Studio. You can download the latest versions from here.
  3. You should have WSL2 installed on your system. This can be easily done through typing the following command in PowerShell

Install appropriate Java version in the WSL2 environment.

Replace the <version> with the appropriate version. In our case, it was 21.

Now, run the same command that was mentioned earlier to install Maestro on Linux.

To validate installation, check if the maestro command returns its version.

Writing a Test Flow

To start writing a test flow, we would need an app under test whose flow we will be automating. You could choose any app of your choice or use the built in samples from the maestro libraries. To download the app samples,

In our case, we are automating just the login flow of an app, separate from the samples.

Line no. 1 we mention the app identifier, which tells the framework which application package to target.

Line no. 3 clears the application state, so that it is in the vanilla state, before the test start running.

Line no. 4 launches app that is under target.

Line no. 5 and 6 taps on the elements with their respective visible texts

Line no. 7 taps an a text input field, which is specified by its id, instead of the visible text on it. Maestro supports multiple location selector strategies like id, text, relative position, element states, etc. Full list of the locator strategies can be referenced here.

Line no. 9 erases the pre-existing text that is present in the text input field.

Line no. 10 enters text into the text input field

Lines 11 through 13 follow similar credentials input flow.

Running a UI Test Automation

Now that we have our framework up and have written a UI test flow, we can write and run our tests on physical and emulated devices.

The great thing about Maestro interfacing with Android devices is that it can automatically detect any locally installed emulator or physical device. No more finding the elusive port to connect to 😅.

For the iOS platform, currently maestro only supports the simulated devices, not physical ones. To get it up to pace, you have to first install the Facebook iOS Development Bridge tool.

For our example, we will be running this on a target android app.

If you do not have an android device or android emulator running already, then the maestro interface will bring up options to list and run from any existing emulator or device. You can also choose to create a new one from the option. Do make sure that the target device has the test application on it.

After device launch maestro will start running the test on it.

Running Maestro Test Flow
Running Maestro Test Flow

Thus, from scratch to a running test flow in less than 15 minutes!

In further posts, we will explore implementation of different type of flows that we can test in the framework.

Share your love
Punit Goswami
Punit Goswami
Articles: 4

Leave a Reply

Your email address will not be published. Required fields are marked *