Run accessibility checks on an Espresso sample repo
Try out App Accessibility Automation with BrowserStack’s sample apps and repository.
Prerequisites
- Ensure you have a BrowserStack Username and Access Key. Obtain your
userName
andaccessKey
from the Account & Profile section on the dashboard.
If you have not yet created an account, sign up for a free trial. - Espresso tests are built into a separate
apk
file from your app. Hence, you will need access to both the app (.apk
or.aab
) and the test suite (separate.apk
file). - Ensure the following are installed on your system:
- Java 11 or later.
- Android Gradle Plugin (AGP) 7.3 or later.
- API level 27 or higher.
- Gradle 7 or later. Make sure you also change the Gradle wrapper properties in your project’s
gradle-wrapper.properties
file. - Cucumber v4 with JUnit v4, or only JUnit v4.
Currently, the BrowserStack SDK doesn’t support Espresso with the JUnit 5 Runner.
Run a sample build
Get the sample app and test suite
- Download BrowserStack’s sample Calculator app and Calculator test suite.
Upload the app
Upload the sample app (.apk
or .aab
file) to the BrowserStack servers using a REST API request.
The following sample cURL command demonstrates how to upload an app:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/app" \
-F "file=@/path/to/app/file/App.apk"
A sample response for the request is shown below:
{
"app_name":"Application-debug.apk",
"app_url":"bs://j3c874f852ea50957a3fdc33f47514288c4ba4",
"app_version":"1.0",
"app_id":"j3c874f852ea50957a3fdc33f47514288c4ba4",
"uploaded_at":"2022-05-12 07:27:54 UTC",
"expiry":"2022-06-11 07:27:54 UTC"
}
Use the app_id
parameter to identify the application when you run Espresso tests.
App upload may take a few seconds to a minute, depending on the size of your app. Do not interrupt the cURL command until you get the response back.
Upload the test suite
Upload the sample test suite (.apk
file) to the BrowserStack servers using a REST API request.
The following sample cURL command demonstrates how to upload a test suite:
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/test-suite" \
-F "file=@/path/to/app/file/Application-debug-test.apk"
A sample response for the request is shown below:
{
"test_suite_name":"Application-debug-test.apk",
"test_suite_url":"bs://f7c874f21852ba57957a3e31f47514288c4ba4",
"test_suite_id":"f7c874f21852ba57957a3e31f47514288c4ba4",
"uploaded_at":"2022-05-12 07:32:41 UTC",
"expiry":"2022-06-11 07:32:41 UTC",
"framework":"espresso"
}
Use the test_suite_id
parameter to identify the test suite when you run Espresso tests.
Run Espresso tests
In a cURL
command, include the following parameters and send the API request to run the test.
-
app
: specify theapp_id
, which is the unique identifier of the application that you want to test. Theapp_id
is generated when you upload the app to BrowserStack, see Upload your app. -
testSuite
: specify thetest_suite_id
, which is the unique identifier of the test suite you want to run. Thetest_suite_id
is generated when you upload your test suite to BrowserStack, see Upload your test suite. -
devices
: specify a list of Android devices on which you want to test your app. For more information, see Specify devices. -
accessibility
: enable accessibility checks.
- In the API request,
app
,testSuite
, anddevices
are mandatory parameters to start the test execution.
- For a complete list of parameters that you can use in your Espresso test execution, see Espresso Build API reference.
curl -u "USERNAME:ACCESS_KEY" \
-X POST "https://api-cloud.browserstack.com/app-automate/espresso/v2/build" \
-d "{
\"app\": \"bs://$app_id\",
\"testSuite\": \"bs://$test_suite_id\",
\"devices\": ["Samsung Galaxy S24-14.0"]
\"deviceLogs\": true,
\"project\": \"$PROJECT_NAME\",
\"accessibility\": true,
}
}" \
-H "Content-Type: application/json"
Response
A sample response for the request is shown below:
{
"message" : "Success",
"build_id" : "4d2b4deb810af077dd98f479bfdd2e64f36c3"
}
The build_id
uniquely identifies your build in App Automate. Each test build is an execution of the Espresso test suite on all selected devices.
If your tests fail with a NO TESTS RAN
error, refer to the No tests ran guide.
View test results
After you run the test using the REST API, visit the App Automate dashboard to view your test results, debug logs, and overall test details.
Visit App Accessibility dashboard
You can also use API requests to view the test results.
Next steps
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!