Are You Running Selenium WebDriver Tests With BrowserStack?
Sept 30, 2016
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 on BrowserStack.
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. This applies to any other browser 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 the 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 browser name 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 the platform and 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:
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.
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 the last run. Debugging is set to false by default. To enable logs, set the BrowserStack custom capability browserstack.debug to true.
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.
Explore Additional Resources
Our organization assists you with improving your marketing strategies. Select the best Digital Strategy to boost your business.
Our Quality Assurance team helps our clients build a managed QA department.
GET HELP FROM OUR EXPERTS
Over the past 19 years, we have completed thousands of digital projects globally. We have one of the largest and deepest multi-solutions digital consulting teams in the world. Our proprietary processes and years of Digital Experience expertise have earned us a 97% customer satisfaction rating with our clients ranging from Global Fortune 1000 to Mid-Market Enterprises, leading educational institutions, and Non-Profits.
Contact us today for help if your organization needs help with Selenium testing.
About TA Digital
TA Digital is an innovative digital transformation agency, specializing in delivering the digital experience, commerce, and marketing solutions. For nearly two decades, we have been helping traditional businesses transform and create dynamic digital cultures through disruptive strategies and agile deployment of innovative solutions.