Integrate TestNG test suite with App Accessibility testing
Learn how to add accessibility checks to your existing functional tests and generate comprehensive reports of accessibility issues.
BrowserStack supports out-of-the-box integration with Cucumber tests using TestNG as a test runner. You can integrate your existing functional test suites with App Accessibility testing to run accessibility checks on mobile apps. You can access the generated accessibility violation reports on the App Accessibility dashboard.
For Android devices, automated App Accessibility testing is supported on version 11 and above.
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. - Ensure Maven or Gradle is installed, with environment variables configured and their
bin
directories added to the system$PATH
. - Ensure the following are installed on your system:
- TestNG v6.8 or higher
- Java 8 or higher. For Gradle, Java 9 or higher.
Integrate App Accessibility Automate to run accessibility checks
Install or update the BrowserStack SDK
The minimum supported BrowserStack SDK version is 1.29.0
.
Install the BrowserStack SDK using the Maven Archetype, which provides a template to quickly configure your project.
- Run the following command to add the
browserstack-java-sdk
dependency to thepom.xml
and thebrowserstack.yml
configuration files of your project.
Follow these steps to update the BrowserStack SDK.
- Update your
pom.xml
file to include the latest version of the BrowserStack SDK:
- Run the following command within your test suite folder from the terminal to update to the latest SDK version:
Modify the configuration file
The browserstack.yml
file defines the required capabilities to run tests on BrowserStack. It is platform-specific and located in the corresponding platform folder (android/
or ios/
). Make sure you modify the file that corresponds to your testing platform.
- Open the
browserstack.yml
file. - Set the
userName
andaccessKey
. - Set the
framework
tocucumber-testng
. - Set the
accessibility
flag totrue
. By default, the flag is set tofalse
. - Configure the
accessibilityOptions
property to set various accessibility testing options. For details, see Configuration options. - Add the relative or absolute path of the app you want to test in the
app
property. For example,app: ./examples/BStackSampleApp.apk
.
You can upload an Android app (.apk
or.aab
file) or an iOS app (.ipa
file) from your local filesystem. - Specify all the device, OS, and OS version combinations that you want to test in the
platforms
section. - Add the
projectName
andbuildName
. - Save the file.
The projectName
and buildName
config must be static and not change across different runs of the same build. This is a deviation in approach as specified by BrowserStack App Automate since Automated tests will automatically identify different build runs.
Run the automated test
From your platform folder (Android or iOS), run the following command:
mvn test -P sample-test
View the Accessibility test report
After the test completes, view the report in your project folder on the App Accessibility dashboard.
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!