Selenium WebDriver automation framework built with Java, Maven, and TestNG. The project demonstrates a clean baseline for browser-based regression testing and is structured to be easy for recruiters, hiring managers, and clients to review.
Manual regression testing for web applications is repetitive, slow, and easy to miss when features change frequently. A reusable automation framework is needed to validate critical user journeys, reduce manual effort, and provide a foundation that can scale into a larger QA automation suite.
This project automates key login scenarios for the public SauceDemo application using Selenium WebDriver and TestNG. It includes reusable browser setup, page-object based test design, configurable execution options, and Maven-based test orchestration.
- Opens the SauceDemo application in a real browser.
- Verifies that the login page loads correctly.
- Validates successful login for a standard user.
- Validates the locked-out user error message.
- Supports Chrome, Firefox, and Microsoft Edge through Selenium Manager.
- Supports headless execution for CI or local background runs.
- Java 17
- Maven
- TestNG
- Selenium WebDriver 4
- SauceDemo test application
.
├── pom.xml
├── testng.xml
├── README.md
└── src
└── test
└── java
├── pages
│ └── LoginPage.java
└── tests
├── BaseTest.java
└── LoginTest.java
Install and verify the following before running the suite:
- Java JDK 17 or later
- Maven 3.9 or later
- Google Chrome, Mozilla Firefox, or Microsoft Edge
- Internet access, because the tests run against
https://www.saucedemo.com
Verify installation:
java -version
mvn -versionSelenium 4 includes Selenium Manager, which can automatically resolve compatible browser drivers when the browser is installed and available on the machine.
Clone the repository and move into the project folder:
git clone <repository-url>
cd java-testng-automation-frameworkInstall project dependencies:
mvn clean test -DskipTestsThe framework can be configured through Maven system properties.
| Property | Default | Description |
|---|---|---|
browser |
chrome |
Browser to run tests on. Supported values: chrome, firefox, edge. |
baseUrl |
https://www.saucedemo.com |
Application URL under test. |
headless |
false |
Runs the browser without a visible UI when set to true. |
Examples:
mvn test -Dbrowser=chrome
mvn test -Dbrowser=firefox
mvn test -Dbrowser=edge -Dheadless=true
mvn test -DbaseUrl=https://www.saucedemo.com -Dheadless=trueRun the full TestNG suite:
mvn testRun using the TestNG suite file explicitly:
mvn test -Dsurefire.suiteXmlFiles=testng.xmlRun in headless Chrome:
mvn test -Dbrowser=chrome -Dheadless=true| Test | Purpose |
|---|---|
loginPageShouldLoad |
Confirms the login page opens and key controls are visible. |
validUserShouldLoginSuccessfully |
Confirms a valid user can log in and view the Products page. |
invalidUserShouldSeeErrorMessage |
Confirms a locked-out user receives the expected error message. |
After execution, Maven and TestNG generate results in:
target/surefire-reports/
test-output/
These folders are ignored by Git because they are generated during test execution.
The repository includes a GitHub Actions workflow at:
.github/workflows/maven-tests.yml
The workflow runs the TestNG suite in headless Chrome on every push, pull request, or manual workflow dispatch for the main and master branches.
CI command:
mvn test -Dbrowser=chrome -Dheadless=trueBaseTestowns browser creation, configuration, navigation, and teardown.LoginPagecontains locators and login-page interactions.LoginTestcontains assertions for user-facing login behavior.testng.xmldefines the suite and included test classes.pom.xmlcontrols dependencies, Java version, and Maven Surefire execution.
- Uses Page Object Model for separation of test logic and page interaction logic.
- Uses explicit waits for stable browser synchronization.
- Uses Maven properties to keep execution configurable.
- Keeps generated files out of version control with
.gitignore. - Avoids hard-coded browser-only execution by supporting Chrome, Firefox, and Edge.
- Add reporting with Extent Reports or Allure.
- Add CI execution through GitHub Actions.
- Add screenshots on failure.
- Add environment-specific configuration files.
- Add more page objects and end-to-end workflows.
- Add parallel execution after the suite grows.
Project-level review and code cleanup have been completed. The suite is ready to run on a machine with Java, Maven, and a supported browser installed.
Local execution in the current environment could not be completed because java and mvn are not available on the system PATH. After installing the prerequisites, run:
mvn testThe project can be marked complete after the Maven test run passes successfully in a properly configured local or CI environment.