Skip to content

PriyaUshadevi/java-testng-automation-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java TestNG Automation Framework

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.

Problem Statement

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.

Solution

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.

Current Scope

  • 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.

Tech Stack

  • Java 17
  • Maven
  • TestNG
  • Selenium WebDriver 4
  • SauceDemo test application

Project Structure

.
├── pom.xml
├── testng.xml
├── README.md
└── src
    └── test
        └── java
            ├── pages
            │   └── LoginPage.java
            └── tests
                ├── BaseTest.java
                └── LoginTest.java

Prerequisites

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 -version

Selenium 4 includes Selenium Manager, which can automatically resolve compatible browser drivers when the browser is installed and available on the machine.

Installation

Clone the repository and move into the project folder:

git clone <repository-url>
cd java-testng-automation-framework

Install project dependencies:

mvn clean test -DskipTests

Configuration

The 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=true

How To Run

Run the full TestNG suite:

mvn test

Run using the TestNG suite file explicitly:

mvn test -Dsurefire.suiteXmlFiles=testng.xml

Run in headless Chrome:

mvn test -Dbrowser=chrome -Dheadless=true

Test Scenarios

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.

Reports And Output

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.

CI/CD

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=true

Framework Design

  • BaseTest owns browser creation, configuration, navigation, and teardown.
  • LoginPage contains locators and login-page interactions.
  • LoginTest contains assertions for user-facing login behavior.
  • testng.xml defines the suite and included test classes.
  • pom.xml controls dependencies, Java version, and Maven Surefire execution.

Code Quality Notes

  • 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.

Future Enhancements

  • 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.

Verification Status

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 test

The project can be marked complete after the Maven test run passes successfully in a properly configured local or CI environment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages