Test Robo Scripts Locally: Useful For Firebase Test Lab & Pre-launch Reports

I found the least known way to test robo scripts locally. Using this, we can be assured that the robo scripts that we have recorded & uploaded for the Google Play Store Pre-launch Report or Firebase Test Lab will work, most probably.

Rohit Surwase
AndroidPub

--

Monkey/Robo Test (Source: https://www.freeimages.com)

I am sure, most Android developers are aware of Firebase Test Lab and Google Play Console Pre-launch Report. These are really useful tools. Today, I am not gonna explain why, when and how to use those tools. But, I am gonna tell you, how can we get the most out of those tools with minimum efforts. So, before we begin with our topic, let me take everyone on the same page.

Robo Script:

Robo Test (similar to Monkey Test) is a test performed by a robo on the target app which usually performs random actions by clicking random UI elements. But, that is not what we want. For example, we might want to test a new user onboarding flow or day-night mode. So, random actions would not satisfy our needs. We would want to have control over robo actions. That’s where robo scripts come into play. Robo Script is a JSON file that has a set of actions (commands that robo can understand 😊) that robo can perform in the given order. And, creating this robo script is also simple, all you have to do is record yourself walking through the desired workflow using Android Studio. You can find this recording option under Android Studio > Tools > Firebase > Test Lab > Record Robo Script. Once done, you have to upload the script file on the Firebase Test Lab and Google Play Console Pre-launch Report console, separately.

Example of a Robo Script

Problem:

Whether it is Firebase Test Lab or Google Play Console Pre-launch Report the robo scripts we have recorded and uploaded do not work as expected most of the time. It fails in-between and we have to retry with another script. But we are already short on the number of retries we can get as Play Console Pre-launch Report runs only when we upload a new APK and with the free plan of Firebase Test Lab, we are allowed to run tests only once in 24hrs. So, there should be a way to test those robo scripts multiple times, locally before we upload it on the console. How can we do this?

After searching in every possible way I was pretty sure that this is not possible as of now so I decided to request this feature as a part of Firebase Assistance Tool in Android Studio. I sent the feature request and I got a response too. Noel from Firebase Support team responded and informed me that this is an interesting feature that can be considered and forwarded it ahead. And after a few days, Noel came up with the solution that he got from the team. Here is the elaborated version of the solution given by him.

Solution:

You might have heard about App Crawler, it is part of Android Jetpack and works the same as Robo Test, that too locally. But the official doc or any other source does not say that we can provide a Robo Script to the App Crawler, right? Let’s see-

Here are the steps to setup App Crawler that can be used for our purpose
(I am assuming you already have a recent version of Android SDK)-

Step 1: Download the crawler binary archive and extract to the directory of your choice.
Step 2: Start an emulator or connect a physical device using a USB cable.
Step 3: Open the terminal/command window where you have extracted the app-crawler binary.

That’s all, simple, isn’t it?

Step 4: You can invoke the crawler to test target apk with random actions, just the way Test Lab does, using the following command-

java -jar crawl_launcher.jar --apk-file <apk-path> --android-sdk <android-sdk-path>

Now, here is the catch, Can we provide our robo script to app crawler? Yes… we can… though the official doc does not say anything about this feature. Thankfully, I got to know about this from Noel and the team.

Step 5: Provide a Robo script to the App crawler using following command-line option-

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

java -jar crawl_launcher.jar --robo-script-file <robo-script-path> --apk-file <apk-path> --android-sdk <android-sdk-path>

Hurray! Mission accomplished.

Now, that we can run and test the robo scripts locally, it is time to fix them. For that, we can use logcat files generated by App Crawler, it is stored under the build > crawl_output directory.

I hope, this helps you.

Useful Resources:

  1. Firebase Test Lab Robo tests
  2. Setup App Crawler
  3. Use pre-launch reports to identify issues : Control how the pre-launch report explores your app

Thanks for reading!
Rohit Surwase

If you liked the article, clap clap clap 👏👏👏 as many times as you can.

LIKED SO MUCH! Medium allows up to 50 claps.
Also, post a Tweet on Twitter.

Let’s be friends on LinkedIn, Medium, Twitter and GitHub.

--

--

Rohit Surwase
AndroidPub

Techie by Birth. Writer by Hobby. Observer by Nature. Unpredictable by Character. Android Developer (Google Certified) by Profession.