Flutter: handle google consent form with automated tests

68 views Asked by At

My Flutter app is using the google_mobile_ads package with the Google User Messaging Platform (UMP) SDK to show a consent form as soon as the app started. I now want to test my app using:

  1. Locally: Flutter integration_test package
  2. Google Play: Pre-launch report (Robo scripts)
  3. Cloud: Firebase Test Lab (Robo scripts)

1) Flutter integration_test

  • With the UMP enabled, I could not find a way to perform a click on the "agree" button or any other element of the consent form using the integration_test package. Interacting with other elements is not a problem.

Any idea how I can handle the consent form using integration_test package?

2) Google Play Pre-launch report

  • When uploading the app to the Google Play store the pre-launch report using the automated Robo tests shows me 10 screenshots of all possible views of the consent form, but only one screen of my app, which is frustrating.
  • The version I upload needs to include the UMP, so there is no way to disable the consent form.
  • But I have the option to add/upload a Robo script to "Testing -> Pre-launch report -> Settings -> Control how pre-launch report explores your app"

What kind of robo script can I add in Google Play console? Any other ways to handle this?

3) Firebase Test Lab

  • Google Play is actually using Firebase Test Lab, so this approach should be the same. With the "Robo tests" option I get the same results as for Google Play, but I could also run custom tests using a "Robo script".
  • In the Robo tests -> Crawl graph I could see "ELEMENT_CLICK:Zustimmen" (which means: agree in German)
  • Robo scripts examples require a ""resourceId":", what should I put there?

Is there a short Robo script I could use to perform this one click?


TLDR: How can I handle the Google UMP Consent Form in automated test environments using Flutter?

1

There are 1 answers

0
Faith On

For pre-launch report and Robo (Roboscript): Besides using resource ID, you can try one of the other element descriptors in your Roboscript to help Robo find the element: https://firebase.google.com/docs/test-lab/android/robo-scripts-reference#element-descriptors

From that page, you can also try using visionText (OCR) descriptions to interact with the element.

This may take some trial and error, since Robo doesn't natively support Flutter. Usually the element's resource ID is a straightforward way to interact with the element, but you may need to set or get this ID specifically for Flutter.