Run a sample App Percy build with Maestro
Run a sample App Percy build with Maestro using the example project and a BrowserStack App Automate session.
This page walks you through running a sample App Percy build with Maestro. You use the example-percy-maestro-app project, which bundles a sample Android calculator app and two Maestro flows. You then run the build on a BrowserStack App Automate Maestro session.
App Percy with Maestro runs only on BrowserStack Maestro sessions, so this sample build runs on BrowserStack App Automate.
Prerequisites
Before you start, ensure you have the following:
- A Percy account with an App Percy project.
- Node.js and npm installed.
- The zip command available on your path.
- Git installed.
- Your BrowserStack username and access key
Run your sample build
To clone the sample project, run a build on BrowserStack, and view the results in App Percy, follow these steps:
Clone the sample project
Clone the example project and install its dependencies:
git clone https://github.com/percy/example-percy-maestro-app
cd example-percy-maestro-app
npm install
This installs @percy/maestro-app and @percy/cli. The project includes a sample Android calculator app at resources/app-debug.apk and two Maestro flows in the flows/ directory:
-
flows/screenshot.yamlcaptures two screenshots of the calculator. -
flows/regions.yamlcaptures two screenshots and masks the status bar and the result field using regions.
Create an App Percy project
Sign in to Percy, create a new project, and select App as the project type. Percy generates a unique PERCY_TOKEN for the project. Copy the token. You pass it in the build payload in a later step.
Upload the sample app
Upload the bundled APK to BrowserStack:
curl -u "BROWSERSTACK_USERNAME:BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/app" \
-F "file=@resources/app-debug.apk"
Note the app_url value in the response. You pass it in the build payload in a later step.
Prepare and upload the test suite
Package the flows along with the App Percy SDK files into a zip:
npm run prepare-zip
Upload the resulting Flows.zip to BrowserStack:
curl -u "BROWSERSTACK_USERNAME:BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/test-suite" \
-F "file=@Flows.zip"
Note the test_suite_url value in the response. You pass it in the build payload in the next step.
Trigger the build with App Percy
Trigger the build, passing your app URL, test suite URL, and Percy token from the previous steps. Set the token in the appPercy object of the payload:
curl -u "BROWSERSTACK_USERNAME:BROWSERSTACK_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/maestro/v2/android/build" \
-H "Content-Type: application/json" \
-d '{
"app": "<APP_URL>",
"testSuite": "<TEST_SUITE_URL>",
"devices": ["Samsung Galaxy S22-12.0"],
"project": "Percy Maestro Example",
"appPercy": {
"PERCY_TOKEN": "<PERCY_TOKEN>"
}
}'
Use the appPercy field to pass your Percy token. The percyOptions field is silently dropped, so screenshots won’t reach your project if you use it.
View the results
The build runs both flows and uploads four screenshots to your App Percy project. Open the project in Percy to review the build. The screenshots from flows/regions.yaml show the status bar and result field masked, so changes inside those regions don’t trigger a visual difference.
When you run another build with visual changes to the app, Percy takes new screenshots. You can then see the comparisons between the two runs on the new build.
Congratulations
You’ve run your first App Percy build with Maestro. From here, you can integrate the SDK into your own Maestro flows.
Related topics
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!