Skip to main content
No Result Found

Automated tests on TestNG

Quick start guide to integrate Automated tests in BrowserStack Accessibility Testing with TestNG.

Prerequisites

  • You have an account with BrowserStack (even a free trial works) and can get the username and access key from Account & Profile.
  • You have a pre-existing TestNG test suite integrated with BrowserStack Automate.
  • Maven or Gradle is installed on your machine, its environment variables are set, and its bin is added to system path, $PATH.
  • TestNG v6.8+, Java v8+ (If using Gradle, Java v9+ is required), Selenium v2.5+ (JSON Wire / W3C).

Integrate with Automated tests

Follow these steps to get started with adding Automated tests to your test suite:

The minimum version of browserstack-java-sdk that supports Automated tests is 1.13.10.

Install or update to the latest BrowserStack Java SDK

If you already use browserstack-java-sdk, update the entry enclosed within the <version> - </version> tags as LATEST in the pom.xml file of your project and run the following command to update to the latest SDK version.

Terminal
Copy icon Copy


If you don’t have browserstack-java-sdk installed already, run the following command on your terminal/command prompt to add browserstack-java-sdk dependency and browserstack.yml file in your project.

mvn archetype:generate -B -DarchetypeGroupId=com.browserstack \
-DarchetypeArtifactId=testng-archetype-integrate -DarchetypeVersion=1.2 \
-DgroupId=com.browserstack -DartifactId=testng-archetype-integrate -Dversion=1.2 \
-DBROWSERSTACK_USERNAME=YOUR_USERNAME -DBROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY

mvn archetype:generate -B -DarchetypeGroupId=com.browserstack -DarchetypeArtifactId=testng-archetype-integrate -DarchetypeVersion=1.2 -DgroupId=com.browserstack -DartifactId=testng-archetype-integrate -Dversion=1.2 -DBROWSERSTACK_USERNAME=YOUR_USERNAME -DBROWSERSTACK_ACCESS_KEY=YOUR_ACCESS_KEY

Modify your browserStack.yml config file

Automated tests mandatorily needs the following five configurations in the browserstack.yml file. Especially, ensure to set the accessibility flag as true 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 Automated tests will automatically identify different build runs.

browserstack.yml
Copy icon Copy
  • Accessibility testing runs only on Desktops (Mac & Windows) with Chrome 100 & above on Automate.

  • Window handle commands might cause instability to Automated Tests. If you face issues, consider removing window handle commands or contact support.

Run your test suite with Automated tests

Continue running your tests as you have been running previously. The command to run your tests using the BrowserStack SDK remains unchanged. For your reference, here’s a sample command:

Copy icon Copy

You can check the Accessibility report for your build through the Automated tests page.


Visit Automated tests page

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 Check Circle