Quality Assurance

Are You Running Selenium WebDriver Tests With BrowserStack?

Are you in a fix over how to run Selenium tests in BrowserStack? This post will offer you all the technical guidance you need to run scripts in BrowserStack, run parallel tests using TestNG, configure XML files, run tests configured in TestNG and debug tests.

Steps to run scripts in BrowserStack

Step 1: Pre-requisites

  1. Running Selenium tests in BrowserStack requires a username and an access key.
  2. To obtain a username and access key, sign up for a free trial or purchase a plan in BrowserStack. (https://www.browserstack.com)

Step 2:  Define capabilities

To run tests on remote machines of BrowserStack, the capabilities of the WebDriver have to be changed accordingly.

For example, to configure it to run on the Firefox browser, we have to define certain capabilities in the code to run it on Firefox Browser. Similarly, for other browsers as well.

Step 3:  Setup to run a script on browser

Browser setup can be done using the Desired Capabilities defined in Step 2. For example, to set up IE-11.0 with Windows 7:

  • Define Capabilities.
  • Set the capability of browser to IE.
  • Set the browser version, OS type, OS version etc.

Step 4:  Setup to run a script on mobile devices

You can also run Selenium test scripts on mobile emulators (e.g., iOS, Android) by specifying the version and device in the input capabilities. These capabilities are browserName and device.

For example, to run a script on iPhone, the capabilities can be defined as mentioned below:

  • Define Capabilities.
  • Set the browser capability for iPhone.
  • Set the capabilities of Platform & device for iPhone.


Step 5:  Testing from a local machine

To run the tests on BrowserStack VMs with scripts from a local machine, you need to download a binary that is appropriate to the OS of the local machine. After downloading the binary, navigate to the folder containing the binary and run it from the command-line interface as shown below:

BrowserStackLocal.exe ACCESS_KEY

Running parallel tests using TestNG

TestNG is a testing framework for the Java programming language, which can be used for various tests (e.g., unit, functional, end-to-end, integration).

Parallel testing using TestNG involves creating test and xml files where you can specify the maximum number of parallel instances the test can run, and the parameters necessary to pass the test.

Debugging tests in BrowserStack


To debug failed tests, BrowserStack provides raw logs, which are the console logs from the browser tests; visual logs, which capture successive screenshots of the test; and text logs to display all the steps that were performed by the test.

Live screencast

With live screencast, you can view ongoing tests to debug the functionality of features that are being tested. The generated videos can be recorded and downloaded for later viewing.

Logs and the live screencast help you to compare and detect any changes that may have occurred since a similar test was last run. Debugging is set to false by default. To enable logs, set the BrowserStack custom capability browserstack.debug to true.

caps.setCapability(“browserstack.debug”, “true”);

Video recording

Videos are recorded for every BrowserStack Automate test. This feature helps you to verify and debug failed tests, confirm the functionality of tested features, and download videos for later viewing.

There you’ve it! A whirlwind tour of running Selenium with BrowserStack. Need additional assistance? Reach out today.

# # #

About The Author

Leave a Reply