This project contains automated UI tests for a web application, developed as part of a testathon. The tests are written in Java using Selenium WebDriver and the TestNG framework. The project is configured to run tests on BrowserStack for cross-browser testing.
- Java: The programming language used to write the tests.
- Selenium WebDriver: For automating browser actions.
- TestNG: As the testing framework for test management and execution.
- Maven: For project build and dependency management.
- BrowserStack: For running tests on a cloud-based grid of browsers and devices.
├── pom.xml
├── Readme.md
├── src
│ └── test
│ └── java
│ └── com
│ └── bs
│ ├── BaseTest.java
│ ├── HackathonTests.java
│ └── HomePageTests.java
└── testng.xml
pom.xml: The Maven Project Object Model file, which defines project dependencies, plugins, and build settings.testng.xml: The TestNG configuration file, used to create test suites and configure test execution parameters.src/test/java/com/bs/: The main directory for the test source code.BaseTest.java: A base class for tests that handles the setup and teardown of the WebDriver, including BrowserStack configuration.HomePageTests.java: Contains end-to-end tests for the main application, including login, add to cart, and checkout flows.HackathonTests.java: Contains additional tests, such as a simple login test.
The project includes the following automated tests:
endToEndFLow(): This test covers the entire user journey from logging in, adding a product to the cart, and successfully placing an order.validateShippingDetailsMandatoryFields(): This test validates that the shipping details form correctly handles mandatory fields.
loginWithValidCredentials(): A simple test to verify that a user can log in with valid credentials.
- Java Development Kit (JDK) 17 or higher.
- Apache Maven.
- A BrowserStack account with your username and access key.
-
BrowserStack Credentials: The BrowserStack username and access key are loaded from environment variables (
BROWSERSTACK_USERNAMEandBROWSERSTACK_ACCESS_KEY) insrc/test/java/com/bs/BaseTest.java. You need to set these environment variables before running the tests.For example, you can set them in your shell:
export BROWSERSTACK_USERNAME="your_username" export BROWSERSTACK_ACCESS_KEY="your_access_key"
-
Test Suite Configuration: The
testng.xmlfile is used to configure which tests to run and on which browsers. You can enable or disable tests and test groups by editing this file.
To run the tests, execute the following command from the root of the project:
mvn clean testThis command will compile the project, download the dependencies, and run the tests as configured in testng.xml.