Loading repository data…
Loading repository data…
BrowserStackCE / repository
This repository showcases the BrowserStack integration features with the Java TestNG framework using the BrowserStack demo app: https://bstackdemo.com/

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful.
This BrowserStack Example repository demonstrates a Selenium test framework written in TestNG with parallel testing capabilities. The Selenium test scripts are written for the open source BrowserStack Demo web application (Github). This BrowserStack Demo App is an e-commerce web application which showcases multiple real-world user scenarios. The app is bundled with offers data, orders data and products data that contains everything you need to start using the app and run tests out-of-the-box.
The Selenium tests are run on different platforms like on-prem, docker and BrowserStack using various run configurations and test capabilities.
Clone the repository
Ensure you have the following dependencies installed on the machine
Maven:
mvn install -DskipTests
Gradle:
gradle clean build
This repository contains the following Selenium tests:
| Module | Test name | Description |
|---|---|---|
| E2E | OrderTest | This test scenario verifies successful product purchase lifecycle end-to-end. It demonstrates the Page Object Model design pattern and is also the default test executed in all the single test run profiles. |
| Login | LoginTest | This test verifies the login workflow with different types of valid login users. |
| Login | LoginFailTest | This test verifies the login workflow error. |
| Login | LoginDataDrivenTest | This test verifies the login for all error cases in a datadriven way |
| Login | LoginDataDrivenReadFromCSVTest | This test verifies the login for all error cases in a datadriven way with CSV-file |
| Login | LoginRequestedTest | This test verifies that the login page is shown when you access the favourites page with being logged in |
| Offers | OfferTest | This test mocks the GPS location for Singapore and verifies that the product offers applicable for the Singapore location are shown. |
| Product | FilterTest | This test verifies that both filter options are working |
| User | UserTest | The first test verifies that the product images load for user: "image_not_loading_user" on the e-commerce application. Since the images do not load, the test case assertion fails. The second test verifies that existing orders are shown for user: "existing_orders_user" |
This infrastructure points to running the tests on your own machine using a browser (e.g. Chrome) using the browser's driver executables (e.g. ChromeDriver for Chrome). Selenium enables this functionality using WebDriver for many popular browsers.
/src/test/resources/drivers folder.Note: The ChromeDriver version must match the Chrome browser version on your machine.
How to run the test?
To run the default test scenario (e.g. End to End Scenario) on your own machine, use the following command:
Maven:
mvn clean test -P on-prem
Gradle:
gradle clean on-prem
To run a specific test scenario, use the following command with the additional 'test' argument:
Maven:
mvn clean test -P on-prem -Dtest=LoginDataDrivenTest
Gradle:
gradle clean on-prem -Ptest-name=LoginDataDrivenTest
where, the argument test or test-name can be any testclass implemented this repository.
Output
This run profile executes a specific test scenario on a single browser instance on your own machine.
How to run the test?
To run the entire test suite on your own machine, use the following command:
Maven:
mvn clean test -P on-prem-suite
Gradle:
gradle clean on-prem-suite
Output
This run profile executes the entire test suite sequentially on a single browser, on your own machine.
BrowserStack provides instant access to 2,000+ real mobile devices and browsers on a highly reliable cloud infrastructure that effortlessly scales as testing needs grow.
Create a new BrowserStack account or use an existing one.
Identify your BrowserStack username and access key from the BrowserStack Automate Dashboard and export them as environment variables using the below commands.
export BROWSERSTACK_USERNAME=<browserstack-username> &&
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
set BROWSERSTACK_USERNAME=<browserstack-username>
set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
Alternatively, you can also hardcode username and access_key objects in the browserstack.yml file.
Note:
In this section, we will run a single test on Chrome browser on Browserstack. To change test capabilities for this configuration, please refer to the bstack-single.yml file.
How to run the test?
Set Environment Variable to pick desired YML file:
export BROWSERSTACK_CONFIG_FILE="src/test/resources/conf/capabilities/bstack-single.yml"
set BROWSERSTACK_CONFIG_FILE="src\test\resources\conf\capabilities\bstack-single.yml"
To run the default test scenario (e.g. End to End Scenario) on your own machine, use the following command:
Maven:
mvn clean test -P bstack-single
Gradle:
gradle clean bstack-single
To run a specific test scenario, use the following command with the additional 'test-name' argument:
Maven:
mvn clean test -P bstack-single -Dtest=LoginDataDrivenTest
Gradle:
gradle clean bstack-single -Ptest-name=LoginDataDrivenTest
where, the argument test or test-name can be any testclass implemented in this repository.
Output
This run profile executes a single test on a single browser on BrowserStack. Please refer to your BrowserStack dashboard for test results.
In this section, we will run the tests in parallel on a single browser on Browserstack. Refer to bstack-parallel.yml file to change test capabilities for this configuration.
How to run the test?
Set Environment Variable to pick desired YML file:
export BROWSERSTACK_CONFIG_FILE="src/test/resources/conf/capabilities/bstack-parallel.yml"
set BROWSERSTACK_CONFIG_FILE="src\test\resources\conf\capabilities\bstack-parallel.yml"
To run the entire test suite in parallel on a single BrowserStack browser, use the following command:
Maven:
mvn clean test -P bstack-parallel
Gradle:
gradle clean bstack-parallel
Output
This run profile executes the entire test suite in parallel on a single BrowserStack browser. Please refer to your BrowserStack dashboard for test results.
In this section, we will run the tests in parallel on multiple browsers on Browserstack. Refer to the bstack-parallel-browsers.yml file to change test capabilities for this configuration.
Set Environment Variable to pick desired YML file:
export BROWSERSTACK_CONFIG_FILE="src/test/resources/conf/capabilities/bstack-parallel-browsers.yml"
set BROWSERSTACK_CONFIG_FILE="src\test\resources\conf\capabilities\bstack-parallel-browsers.yml"
How to run the test?
To run the entire test suite in parallel on multiple BrowserStack browsers, use the following command:
Maven:
mvn clean test -P bstack-parallel-browsers
Gradle:
gradle clean bstack-parallel-browsers
git clone https://github.com/browserstack/browserstack-demo-app