Skip to main content

Accessibility Automation on TestNG

Quick start guide to integrate BrowserStack Accessibility Automation with TestNG

Pre-requisites

  • You have an account with BrowserStack (even free trial works) and can get the username and access key from Settings.
  • You have a pre-existing TestNG test suite.

Integrate with Accessibility Automation

Follow the steps below to get started with adding Accessibility Automation to your test suite:

Verify your pom.xml entries

Since, you’re an existing browserstack-java-sdk user, you must already have the following entry in your pom.xml file of your project. Please verify that the following exists:

pom.xml
Copy icon Copy snippet

Install the latest SDK version

The previous step outlines that your pom.xml must have the LATEST tag against the browserstack-java-sdk. Now, run the below command to ensure that the latest version is installed:

BrowserStack SDK is a very powerful tool which you can use to set the different browser/device combinations and parallelization. For more details, check out the Automate Integration guide.

Terminal
Copy icon Copy snippet

Verify your browserStack.yml config file

Since you’re an existing browserstack-java-sdk user, you must already be having a browserstack.yml config file at the root level of your project.

Accessibility Automation mandatorily needs the following five configurations in the file. Specifically, make sure to add the accessibility flag at the end of the browserstack.yml 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 Automate since Accessibility Automation will automatically identify different build runs.

browserstack.yml
Copy icon Copy snippet

Accessibility testing will only run on Desktops (Mac & Windows) with Chrome 95 & above on Automate.

Run your test suite with Accessibility Automation

Run the following command from the project’s root directory to run your test suite with BrowserStack.

Copy icon Copy snippet

You can check the Accessibility report for your build through the Accessibility Automation dashboard.

Visit Accessibility Automation Dashboard

To start using BrowserStack Accessibility Automation with your existing setup of TestNG tests running on BrowserStack Automate, you’d need to integrate with the browserstack-java-sdk (if not already done). Follow one of the methods below to integrate the SDK and start using Accessibility Automation:

If you’re an existing browserstack-java-sdk user, you can skip the steps below. All you’d need to ensure is that you’ve specified static names (names should not change across build runs) for projectName and buildName in the browserstack.yml file in your project.

Set BrowserStack credentials

Saving your BrowserStack credentials as environment variables makes it easier to run your test suite from your local or CI environment.

Copy icon Copy snippet
Copy icon Copy snippet

Install BrowserStack SDK using Maven Archetype

Maven Archetype provides a template to quickly configure your project. Copy & run the below command on your terminal/command prompt to add browserstack-java-sdk dependency in your pom.xml and browserstack.yml config file in your project.

BrowserStack SDK is a very powerful tool which you can use to set the different browser/device combinations and parallelization. For more details, check out the Automate Integration guide.

Copy icon Copy snippet
Copy icon Copy snippet

Make changes in your browserstack.yml config file

Once you have installed the SDK, a browserstack.yml config file will be created at the root level of your project. This file holds all the required capabilities to run tests on BrowserStack.

Make sure you copy the contents of the below config file and set it in your project’s browserstack.yml 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 Automate since Accessibility Automation will automatically identify different build runs.

browserstack.yml
Copy icon Copy snippet

Accessibility testing will only run on Desktops (Mac & Windows) with Chrome 95 & above on Automate.

Run your test suite with Accessibility Automation

Run the following command from the project’s root directory to run your test suite with BrowserStack.

Copy icon Copy snippet

Post build run completion, you will see the build URL of Accessibility Automation. Alternatively, you can also navigate to your build run through the Accessibility Automation dashboard.

Visit Accessibility Automation Dashboard

Set BrowserStack credentials as environment variables

Saving your BrowserStack credentials as environment variables makes it easier to run your test suite from your local or CI environment.

Copy icon Copy snippet
Copy icon Copy snippet

Add BrowserStack SDK dependency in pom.xml

Add browserstack-java-sdk as a maven dependency in your pom.xml file. Refresh the project.

BrowserStack SDK is a very powerful tool which you can use to set the different browser/device combinations and parallelization. For more details, check out the Automate Integration guide.

pom.xml
Copy icon Copy snippet

Modify your build plugins

Add the following build plugin

Add maven-dependency-plugin as a plugin under your <build> plugin to resolve dependencies.

Add BrowserStack SDK as an argline property

Add the following java agent <argLine> in your <build> plugin. This step invokes our SDK when your build is triggered.

-javaagent:${com.browserstack:browserstack-java-sdk:jar}

pom.xml
Copy icon Copy snippet

Create browserstack.yml file

Create browserstack.yml file in the root folder of your test suite and add the below code to it:

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 Automate since Accessibility Automation will automatically identify different build runs.

browserstack.yml
Copy icon Copy snippet

Accessibility testing will only run on Desktops (Mac & Windows) with Chrome 95 & above on Automate.

Run your test suite

Right-click your pom.xml file and click Run AsMaven Test:
Eclipse IDE Configuration

Facing issues with TestNG Plugin?

If you encounter the following error, use these steps to resolve the issue: TestNG Runner Error

  1. Get .m2 repository path for browserstack-java-sdk jar .m2 repository path
  2. Pass the .m2 repository path in argline of maven-surefire-plugin in your pom.xml Modify argline
  3. Now you can run tests using TestNG Plugin

View results and insights on Accessibility Automation dashboards

Post build completion, visit the Accessibility Automation dashboard to view the accessibility report for your build.

Visit Accessibility Automation Dashboard

Set BrowserStack credentials as environment variables

Saving your BrowserStack credentials as environment variables makes it easier to run your test suite from your local or CI environment.

Copy icon Copy snippet
Copy icon Copy snippet

Add BrowserStack SDK dependency in your pom.xml

Add browserstack-java-sdk as a maven dependency in your pom.xml file. Refresh the project.

BrowserStack SDK is a very powerful tool which you can use to set the different browser/device combinations and parallelization. For more details, check out the Automate Integration guide.

pom.xml
Copy icon Copy snippet

Create browserstack.yml file

Create browserstack.yml file in the root folder of your test suite and add the adjacent code to it

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 Automate since Accessibility Automation will automatically identify different build runs.

browserstack.yml
Copy icon Copy snippet

Accessibility testing will only run on Desktops (Mac & Windows) with Chrome 95 & above on Automate.

Run your test suite with Accessibility Automation

Get browserstack-java-sdk .m2 repository path

Search for the browserstack-java-sdk jar in External Libraries. Right-click the .jar file, select Copy Path/References, and then copy the absolute path:
Intellij IDEA Configuration

Example Paths:

Mac or Linux: /Users/User_Name/.m2/repository/com/browserstack/browserstack-java-sdk/1.0.9/browserstack-java-sdk-1.0.9.jar

Windows: C:\Users\User_Name\.m2\repository\com\browserstack\browserstack-java-sdk\1.0.9\browserstack-java-sdk-1.0.9.jar

Add browserstack-java-sdk .m2 repository path in VM arguments

In your TestNG Runner file, click the run icon & select Modify Run Configurations:

Intellij IDEA Configuration

Add .m2 repo path from previous step in VM options field. Click Apply and then click OK:

Intellij IDEA Configuration

After successful completion of the above steps, you can now run your test suite using BrowserStack.

View results and insights on Accessibility Automation dashboards

Post build completion or even during the build is running, visit the Accessibility Automation dashboard for detailed insights and deep debugging capabilities.

Visit Accessibility Automation 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






Thank you for your valuable feedback

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy