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 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 20 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 the only global boutique agency that delivers the “best of both worlds” to clients seeking to achieve organizational success through digital transformation. Unlike smaller, regional agencies that lack the ability to scale or large organizations that succumb to a quantity-over-quality approach, we offer resource diversity while also providing meticulous attention to the details that enable strategic success.
Over the past 20 years, TA Digital has positioned clients to achieve digital maturity by focusing on data, customer-centricity and exponential return on investment; by melding exceptional user experience and data-driven methodologies with artificial intelligence and machine learning, we enable digital transformations that intelligently build upon the strategies we set into motion. We are known as a global leader that assists marketing and technology executives in understanding the digital ecosystem while identifying cultural and operational gaps within their business – ultimately ushering organizations toward a more mature model and profitable digital landscape.
Recognized in 2013, 2014, 2015, 2019, and 2020 Inc. 5000 list as one of the most successful technology companies in the United States, TA Digital is pleased also to share high-level strategic partnerships with world class digital experience platform companies like Adobe, SAP and Salesforce and possess global partnerships with industry leaders such as Sitecore, Episerver, Elastic Path, BigCommerce, AWS, Azure and Coveo.