Skip to content

$ cat run-maestro-tests-on-real-android-devices-using-aws-device-farm.md

Run Maestro tests on real Android devices using AWS Device Farm

Learn how to run Maestro YAML test flows on real Android devices in AWS Device Farm using a custom test environment. The guide covers packaging flows, installing Java 21 and the Maestro CLI through a test spec, and collecting artifacts from the run.

AWS DevOps Blog06 Nov 2026 · 8 min read · summary
Read on aws.amazon.com ↗
ManoMano is a European online marketplace for home improvement and gardening products. Their mobile engineering team builds a React Native application that serves millions of customers across Europe. To verify app quality across a wide range of Android devices, ManoMano adopted Maestro for end-to-end (E2E) testing and needed a way to run these tests at scale on real hardware. This post shares how they solved that challenge using AWS Device Farm. In this post, you learn how to run Maestro mobile UI tests on real Android devices using AWS Device Farm. Maestro is a mobile UI testing framework that uses a declarative YAML syntax to describe test flows. By using the custom test environment in AWS Device Farm, you can install and run Maestro flows on real physical devices in the cloud. This post is for mobile developers and Quality Assurance (QA) engineers who use Maestro for E2E testing and want to scale their test suites across real Android devices with different brands, screen sizes, and OS versions. Many teams that adopt React Native prefer Maestro for its YAML-based simplicity and reliable mobile testing capabilities. With the custom test environment feature in AWS Device Farm, you can run any framework that operates over Android Debug Bridge (ADB), including Maestro. This post shows you how to set it up end to end. Solution overview AWS Device Farm is a fully managed app testing service that you can use to test your Android and iOS apps on physical devices in the AWS Cloud. It provides officially supported frameworks (Appium, Espresso, and XCTest) with all dependencies and setup pre-configured. It also offers custom test environments that give you full control over the test host. This means you can install and run any framework that operates over ADB, including Maestro. The custom environment provides the following capabilities: An Amazon Linux 2023 host machine with ADB pre-installed, fully cleaned up and not reused between runs. ADB connectivity to the physical device under test. The ability to install additional tooling through shell commands in the test spec from your test package, downloaded from the internet or accessed through private sources within your virtual private cloud (VPC). Live log and video streaming during test execution. Full artifact collection (logs, screenshots, and other test output) from specified directories. With these capabilities, you can install the Maestro CLI and, if needed, its primary dependency (for example, Java 21) on the test host. You then run your YAML-based test flows against the connected device, the same way you run them locally. Figure 1: Solution architecture How it works The solution uses the following workflow: AWS Device Farm provisions a real Android device and an Amazon Linux 2023 test host with ADB access to the device. During the install phase, the test spec downloads and installs Amazon Corretto 21 (Java) and the Maestro CLI on the test host. During the test phase, Maestro connects to the device through ADB and runs your .yaml test flows. Maestro writes screenshots, video recordings, and test results to the $DEVICEFARM_LOG_DIR directory. AWS Device Farm collects all artifacts and makes them available for download after the run completes. Note: This approach currently supports Android devices only. As of 2026, Maestro iOS support is optimized for simulators and does not work with the real physical iOS devices that AWS Device Farm provides (as indicated in the Maestro documentation). Prerequisites To complete this walkthrough, you must have the following: An AWS account with access to AWS Device Farm An Android .apk file built for testing (a release build with animations disabled is recommended for stability) Maestro test flows written in YAML (for more information, see Getting started in the Maestro documentation) Familiarity with the AWS Device Farm Console The Maestro driver APKs (dev.mobile.maestro) for uploading as Extra Apps in AWS Device Farm. After running Maestro locally at least once on a connected device, you can extract the installed APKs using adb shell pm path dev.mobile.maestro. Walkthrough Complete the following steps to configure and run Maestro tests on AWS Device Farm. Step 1: Prepare your Android application package Build your React Native (or native Android) application as an .apk file. Use a release build or a dedicated test build with animations disabled to reduce test flakiness. Step 2: Package your Maestro test flows AWS Device Farm expects a test package in .zip format. Use this zip file as a carrier for your Maestro .yaml flows. The following example shows a typical test directory structure: .maestro/ ├── login_flow.yaml ├── checkout_flow.yaml └── search_flow.yaml Run the following command to package the directory into a zip file: zip -r maestro-tests.zip .maestro/ Upload this zip file to AWS Device Farm as your test package. AWS Device Farm extracts it to $DEVICEFARM_TEST_PACKAGE_PATH, which makes your flows accessible during test execution. Step 3: Configure the test run In the AWS Device Farm Console, create a test run with the following configuration: For Choose your application, upload your .apk file. For Test framework, select Appium Node.js. This selection determines the expected format of the test package you upload. Appium Node.js accepts a generic zip file containing your test scripts and binaries, which makes it suitable for packaging Maestro flows and the Maestro CLI. Other framework options (such as Instrumentation) require framework-specific package formats like compiled jar files. For Test package, select the zip file that contains your .maestro directory. For Test spec, replace the default testspec.yml with the custom configuration in Step 4. For Devices, select a curated device pool or specific Android devices. For Extra Apps (located under Additional configuration and then Install other apps), upload the Maestro driver APKs (dev.mobile.maestro). AWS Device Farm installs these on the device before the test begins to help you maintain compatibility with restrictive Android skins. Review your configuration and choose Confirm and start. Step 4: Configure the test specification The following test spec instructs AWS Device Farm to download Amazon Corretto 21, install the Maestro CLI, and run your test flows. In the following code, replace {YOUR_APP_ID} with your application package ID (for example, com.example.myapp). You can find this in your application’s AndroidManifest.xml or by running adb shell pm list packages | grep <your-app-keyword>. version: 0.1 # Use the Amazon Linux 2023 host environment android_test_host: amazon_linux_2023 phases: install: commands: # Set locale (important if your app uses special characters) - export LANG=en_US.UTF-8 - export LC_ALL=en_US.UTF-8 - export LANGUAGE=en_US.UTF-8 - locale # Install Amazon Corretto 21 (required by Maestro) - echo "Downloading Amazon Corretto 21..." - curl -L -o /tmp/java21.tar.gz https://corretto.aws/downloads/latest/amazon-corretto-21-x64-linux-jdk.tar.gz - mkdir -p /tmp/java21 - tar -xzf /tmp/java21.tar.gz -C /tmp/java21 --strip-components=1 - export JAVA_HOME=/tmp/java21 - export PATH=$JAVA_HOME/bin:$PATH - java -version # Install Maestro CLI - curl -Ls "https://get.maestro.mobile.dev" | bash - export PATH="$PATH:$HOME/.maestro/bin" pre_test: commands: # Grant background permissions to Maestro driver (for MIUI devices) - adb shell appops set dev.mobile.maestro RUN_IN_BACKGROUND allow 2>/dev/null || true - adb shell appops set dev.mobile.maestro START_ACTIVITIES_FROM_BACKGROUND allow 2>/dev/null || true - maestro --version test: commands: # Run Maestro test flows - maestro test -e APP_ID={YOUR_APP_ID} "$DEVICEFARM_TEST_PACKAGE_PATH/.maestro" --test-output-dir=$DEVICEFARM_LOG_DIR/maestro-results post_test: commands: - echo "E2E tests completed" artifacts: # Collect all Maestro output (screenshots, videos, logs) - $DEVICEFARM_LOG_DIR For more information, see Custom test environments in AWS Device Farm. Key environment variables The test spec uses the following AWS Device Farm environment variables: $DEVICEFARM_TEST_PACKAGE_PATH: The path where AWS Device Farm extracts your uploaded test package (zip file). $DEVICEFARM_LOG_DIR: The default directory for storing artifacts. AWS Device Farm collects files from this directory after the run. $DEVICEFARM_APP_PATH: The path to your uploaded .apk file on the test host. $DEVICEFARM_DEVICE_NAME: The unique device identifier (UDID) of the device under test. $DEVICEFARM_DEVICE_OS_VERSION: The Android OS version running on the device. Reviewing test results After the test run completes, AWS Device Farm displays results organized into three suites: Setup suite: Contains the output from the install and pre_test phases, including Amazon Corretto and Maestro installation. Tests suite: Contains the output from the maestro test command, with pass/fail status for each flow. Teardown suite: Contains the post_test phase output and device cleanup. Figure 2: AWS Device Farm test run results showing the Setup, Tests, and Teardown suites In the Test Specification Log, you can view the live console output. The following example shows typical output during a test run: [DEVICEFARM] Setting up your device. This usually takes 2-3 minutes. [DEVICEFARM] ########### Start executing testspec ########### [DEVICEFARM] ########### Entering phase install ########### [DeviceFarm] echo "Downloading Amazon Corretto 21..." Downloading Amazon Corretto 21... [DeviceFarm] java -version openjdk version "21.0.11" 2026-04-21 LTS OpenJDK Runtime Environment Corretto-21.0.11.10.1 (build 21.0.11+10-LTS) [DeviceFarm] curl -Ls "https://get.maestro.mobile.dev" | bash Installation was successful! [DEVICEFARM] ########### Entering phase test ########### [DeviceFarm] maestro test -e APP_ID=com.manomano "$DEVICEFARM_TEST_PACKAGE_PATH/.maestro" --test-output-dir=$DEVICEFARM_LO

source

This is a summary of an article first published by AWS DevOps Blog. The full piece is on their site.

Open original