Run a Robo script (Android)

This document describes how to useRobo scripts, which are tests thatautomate manual QA tasks for mobile apps, and enable continuous integration(CI) and pre-launch testing strategies. For example, you can use Robo scriptsto test a common user journey or provide specific user interface (UI) input,like a username and password. Robo scripts are a feature ofRobo test.

With Robo scripts, you record yourself walking through a workflow in your app,then you upload that recording to theFirebase console to run in Robotests. When you run a Robo test with a script attached, Robo first stepsthrough your pre-scripted actions and then explores the app as usual.

Robo scripts useRobo testas the test engine. In its most basic form, a Robo script consists of asequence of UI actions likeenter text 'username' andthentap the OK button. Robo scripts can also include actions like waitingfor an element to appear, tapping at a specific point within an element, andexecuting Android Debug Bridge (adb) shell commands.

Robo scripts have the following advantages over traditional testing frameworks:

CapabilityDescription
Highly robustRobo scripts can tolerate significant structural and behavioral differences between app versions and app flakiness.
Open-endedAfter a Robo script completes, the base Robo test can take over and continue testing the app. This continued testing approach enables several key use cases. For example, you can use a Robo script to bring an app into a particular state by performing a custom sign-in flow.
RecordableYou don't need to code Robo scripts manually. They can be recorded using the Robo script recorder in Android Studio. Creating or modifying Robo scripts typically doesn't require any knowledge of mobile development.
FlexibleRobo scripts can interact with non-native UI elements that are common in games.

Robo scripts are conditionally triggered during a Robo test, which lets usersaugment Robo's behavior - typically to achieve greater coverage or targetspecific functionality. In contrast to traditional testing frameworks,Robo scripts support the following:

  • Various triggering conditions, for example, a particular app package namebeing active (or not) or a specific element being displayed on the screen(or not).
  • Execution controls, for example, a maximum number of executions, priority,relevant crawl stage.
  • Unconventional action types (conditional, element-ignoring, screen-closing).

We recommend that you use Robo scripts whenever possible because they can bemaintained effortlessly. For example, you can use a Robo script to do thefollowing:

  • Navigate significant workflows to get to the core of an app's functionality.For example, you can perform a sign-in, set up an app's state after thefirst launch, and register a new user.
  • Focus Robo on a particular part of an app to get the most out of Robo testtime. Robo script guides Robo test to reach the relevant part of an app,where Robo test resumes a fully automated crawl.
  • Bring an app into a specific state or screen to perform an analysis, forexample, to analyze an in-app message, privacy policy, or specific levelof a game.
  • Perform an end-to-end instrumentation test, with or without Robo testresuming a fully automated crawl after the Robo script is complete.

Use more advanced Robo script features to do the following:

  • Perform actions before Robo starts crawling the app-under-test or after acrawl is finished, for example, clean the app-under-test data before acrawl, or change device settings.
  • Change aspects of Robo behavior during a crawl, in particular:
    • Make Robo ignore some UI widgets or app screens.
    • Provide a custom action for Robo to perform when backtracking from aparticular screen.
    • Make Robo perform specific actions whenever a particular app screen isencountered during a crawl.
  • Completely customize how Robo performs a crawl. For example, use acombination of conditional and non-conditional actions to keep theapp-under-test in the background throughout the crawl, while performingdevice manipulations and dismissing any popup dialogs that appear alongthe way.

Keep in mind that Robo scripts don't replace all kinds of tests. You stillneed unit tests to catch low-level logic bugs in your app; these teststypically don't require an Android or iOS environment. We recommend that yousupplement Robo script tests with targeted instrumentation tests that can havespecific, detailed assertions about business logic, which are best expressedin code.

Record a Robo script usingTest Lab in Android Studio

The Robo script recorder in Android Studio lets you record Robo scripts byinteracting directly with the app on your device. Follow these instructionsto get started with Robo scripting through the Firebase tool in Android Studio:

  1. OpenAndroid Studio and selectTools -> Firebase.

  2. In the Firebase pane, clickRecord Robo Script and Use it to Guide Robo Test.

  3. ClickRecord Robo script. The Select Deployment Target dialogappears.

  4. Select the device in which you want to record the Robo script.

  5. After you record the Robo script in the device, save the file as a JSON filein the desired location.

  6. Open theTest Lab page in theFirebase console and upload the JSONscript file and the application APK.

  7. Click theContinue button. You are prompted to select the device andAPI level. After the test script completes,Test Lab generates thetest report.

  8. (Optional) To copy or download the logcat of the test report and the video,clickView Source Files.

Note: Robo script recordings don't capture your actions outside the tested app.For example, sign-ins through Facebook, Twitter, and other social apps aren'trecorded.

By default, Robo script robustness mechanisms prevent it from failing early.If you choose thestrict execution mode and a Robo script fails at any point,Test Lab abandons all further steps in the script and resumes a regularRobo crawl. Most often, Robo scripts fail because Robo can't find a requiredelement on the screen. To avoid failures, make sure that your app navigation ispredictable and that your screens are shown in a deterministic order.

Run a Robo script inTest Lab

To run a Robo script inTest Lab, follow these instructions:

  1. Open theTest Lab page in theFirebase console.

  2. Upload the app’s APK or AAB in theApp APK or AAB field.

  3. Upload your recorded or manually created Robo script file in theRobo script (optional) field.

Provide a Robo script to a local Robo test run

To provide a Robo script to a local Robo test run, use the following Robo testoption:

--robo-script-file <robo-script-path>

Replace<robo-script-path> with a path to your Robo script file in the localfile system. Follow theinstructions for a local Robo testrun.

Specify a Robo script in a gcloud CLI test invocation

To specify a Robo script in a gcloud CLI test invocation, use the followinggcloud CLI flag:

--robo-script = <robo-script-path>

Replace<robo-script-path> with a path to your Robo script file in the localfile system or inCloud Storage usinggs:// notation. For example:

gcloud firebase test android run --app = <path_to_app_apk_file> --robo-script = <robo-script-path>

Next steps

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.