Integrate Serenity 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 Serenity. You can integrate your existing functional test suites with App Accessibility Automate to run accessibility checks on your mobile apps. You can access the generated accessibility violation reports on the App Accessibility dashboard.
For Android devices, App Accessibility automated tests are supported on version 11 and above.
Prerequisites
- Ensure you have a BrowserStack Username and Access Key. Obtain your
username
andaccess key
from the Account & Profile section on the dashboard.
If you have not yet created an account, sign up for a Free Trial. - Ensure you have a functional Serenity test suite. To set one up, see Run accessibility checks on a sample repo.
- Ensure you have the following installed and configured in your system’s
PATH
:
Integrate App Accessibility Automate to run accessibility checks
Integrate BrowserStack automate with your test-suite based on the preferred method you use to build your project.
Set your BrowserStack credentials
Save your BrowserStack credentials as environment variables to simplify running your test suite from your local or CI environment.
Set the following values in either your Zsh (~/.zprofile
) or Bash (~/.profile
) shell conifguration file.
export BROWSERSTACK_USERNAME=YOUR_USERNAME
export BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY
In your terminal or command-line prompt, enter the following command:
setx BROWSERSTACK_USERNAME "YOUR_USERNAME"
setx BROWSERSTACK_ACCESS_KEY "YOUR_ACCESS_KEY"
set BROWSERSTACK_USERNAME=YOUR_USERNAME
set BROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY
Install BrowserStack SDK using Maven archetype
Run the following command in your terminal or command-line to add the browserstack-java-sdk
dependency and browserstack.yml
file to your project.
mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \
-DarchetypeArtifactId=browserstack-sdk-archetype-integrate -DarchetypeVersion=1.0 \
-DgroupId=com.browserstack -DartifactId=browserstack-sdk-archetype-integrate
-Dversion=1.0 \
-DBROWSERSTACK_USERNAME=YOUR_USERNAME -DBROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY
-DBROWSERSTACK_FRAMEWORK=serenity
mvn archetype:generate -B -DarchetypeGroupId="com.browserstack" -DarchetypeArtifactId="browserstack-sdk-archetype-integrate" -DarchetypeVersion="1.0" -DgroupId="com.browserstack" -DartifactId="browserstack-sdk-archetype-integrate" -Dversion="1.0" -DBROWSERSTACK_USERNAME=""YOUR_USERNAME"" -DBROWSERSTACK_ACCESS_KEY="YOUR_ACCESS_KEY" -DBROWSERSTACK_FRAMEWORK="serenity"
Add serenity-browserstack dependency in pom.xml
Add the Serenity BrowserStack plugin to your project dependencies.
- Navigate to root directory.
cd Android
- Add
serenity-browserstack
as Maven dependency in yourpom.xml
file and save the file.<dependency> <groupId>net.serenity-bdd</groupId> <artifactId>serenity-browserstack</artifactId> <version>3.3.4</version> </dependency>
- Navigate to root directory.
cd ios
- Add
serenity-browserstack
as Maven dependency in yourpom.xml
file and save the file.<dependency> <groupId>net.serenity-bdd</groupId> <artifactId>serenity-browserstack</artifactId> <version>3.3.4</version> </dependency>
Update the serenity configuration file
The BrowserStack sample project uses the Serenity BrowserStack plugin. Therefore, you must set your BrowserStack credentials in the serenity.conf
file in the src/test/resources
directory of your test platform (Android or iOS).
- Navigate to the
resources
directory of your preferred platform:cd android/src/test/resources
- Add your credentials to the
serenity.conf
file:webdriver { driver = remote remote.url = "https://hub.browserstack.com/wd/hub" remote.driver = "appium" } browserstack.user="YOUR_USERNAME" browserstack.key="YOUR_ACCESS_KEY"
- Navigate to the
resources
directory of your preferred platform:cd ios/src/test/resources
- Add your credentials to the
serenity.conf
file:webdriver { driver = remote remote.url = "https://hub.browserstack.com/wd/hub" remote.driver = "appium" } browserstack.user="YOUR_USERNAME" browserstack.key="YOUR_ACCESS_KEY"
Modify the BrowserStack configuration file
The browserstack.yml
file defines the capabilities needed to run your tests on BrowserStack. It is located in your project’s root directory and is included in the downloaded sample.
- Open the
browserstack.yml
file. - Add your
userName
andaccessKey
. - Add the
projectName
andbuildName
. - Set the
framework
toserenity
. - 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.
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.
View the Accessibility test report
After the test completes, access 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!