Selenium E2E Test Automation Framework with Java by Faisal IqbalSelenium E2E Test Automation Framework with Java by Faisal Iqbal

Selenium E2E Test Automation Framework with Java

Faisal Iqbal

Faisal Iqbal

Selenium E2E Automation Framework

Project Overview

This project demonstrates a maintainable end-to-end UI automation framework built with Java 17, Selenium WebDriver, TestNG, and Maven against the SauceDemo shopping application.
The framework uses the Page Object Model to separate page interactions from test logic, condition-based explicit waits for reliable synchronization, and TestNG DataProviders for data-driven scenarios. Configuration such as browser selection and timeout values is externalized so executions can be controlled without changing test code.
The automated suite covers core user journeys including authentication, product browsing and sorting, cart operations, checkout, validation errors, logout, and negative scenarios. Framework-level reliability checks also verify browser cleanup and failure-handling behavior.
The complete suite contains 27 test invocations and has been validated successfully on both supported browsers:
Chrome: 27/27 passed
Firefox: 27/27 passed
Failures: 0
Skipped: 0
Execution: Cross-browser through Selenium WebDriver
Reporting: ExtentReports with failure screenshot support
CI/CD: GitHub Actions

The Challenge

End-to-end UI automation becomes difficult to maintain when browser interactions, locators, synchronization logic, test data, and assertions are tightly coupled inside individual tests. As coverage grows, this can lead to duplicated code, unstable synchronization, and tests that are difficult to extend or troubleshoot.
The objective of this project was to build a Selenium framework that keeps browser and page interactions separate from business-level test scenarios, while supporting realistic positive and negative user journeys across multiple browsers.
The framework also needed to provide reliable synchronization without fixed sleeps, preserve useful evidence when failures occur, and execute consistently both locally and through CI.
Key objectives:
Implement reusable page interactions using the Page Object Model
Cover complete business flows across login, inventory, cart, and checkout
Support both Chrome and Firefox
Use condition-based explicit waits instead of fixed sleeps
Use TestNG DataProviders for data-driven scenarios
Externalize browser and timeout configuration
Generate automated ExtentReports
Capture screenshots when browser-based tests fail
Ensure browser cleanup still occurs when evidence/reporting operations fail
Execute and validate the complete suite through GitHub Actions

Framework Architecture

The framework separates browser lifecycle management, page interactions, test scenarios, configuration, and reporting into dedicated components. This keeps test classes focused on business validation while reusable Selenium behavior remains centralized.
BaseTest manages browser creation, validates configuration, applies WebDriver timeouts, and guarantees driver cleanup after browser-based tests.
Page Objects encapsulate locators and reusable interactions for the login, inventory, product details, cart, and checkout pages. A shared BasePage provides common explicit-wait and WebDriver interaction behavior.
Test Classes contain the business scenarios and assertions. TestNG DataProviders are used where multiple inputs or workflow variations need to be validated without duplicating test methods.
Utilities & Configuration manage external configuration, ExtentReports, TestNG listener behavior, screenshots, and execution evidence. Browser and timeout settings can be overridden without modifying the test implementation.

Architecture flow

Configuration → BaseTest → Page Objects → Test Scenarios → Assertions → Reporting & Failure Evidence
Selenium framework architecture in VS Code, showing centralized browser lifecycle management in BaseTest alongside dedicated Page Object, test, utility, and configuration layers with Chrome and Firefox support.
Selenium framework architecture in VS Code, showing centralized browser lifecycle management in BaseTest alongside dedicated Page Object, test, utility, and configuration layers with Chrome and Firefox support.

Page Object Model & Synchronization

Page interactions are encapsulated within dedicated Page Objects rather than being implemented directly inside test classes. The framework includes page objects for login, inventory, product details, cart, and checkout workflows, with shared Selenium behavior centralized in BasePage.
This separation keeps locators and browser interactions out of business-level tests, making the suite easier to maintain when application behavior or UI elements change.
Synchronization is handled through condition-based explicit waits. The framework waits for meaningful application states such as page readiness, destination URLs, expected field or text values, cart counts, removed elements, and sorted product results.
No fixed sleeps, automatic retries, or JavaScript-click workarounds are used. Tests therefore synchronize against observable application behavior rather than arbitrary delays.
Shared BasePage implementation centralizing reusable Selenium interactions and condition-based explicit waits for element visibility, clickability, input values, text, and navigation state.
Shared BasePage implementation centralizing reusable Selenium interactions and condition-based explicit waits for element visibility, clickability, input values, text, and navigation state.

Automated Test Coverage

The suite exercises complete user workflows rather than limiting coverage to isolated UI interactions. Tests are organized around the major functional areas of the SauceDemo application, including authentication, inventory, product details, cart management, and checkout.
The project contains 24 business scenarios plus 3 framework reliability checks, resulting in 27 test invocations. TestNG DataProviders are used to expand scenarios such as login validation, product sorting, and required checkout-field validation without duplicating test implementations.
Coverage includes positive and negative authentication, all four product sorting modes, product-detail validation, cart additions and removals, checkout completion and cancellation, required-field validation, logout behavior, and protected-page access.
Framework reliability is tested separately to verify cleanup after screenshot or reporting failures and to ensure invalid timeout configuration is rejected before browser execution.
Data-driven authentication coverage using TestNG, combining successful login validation with reusable negative scenarios for invalid credentials, locked-out users, and required-field validation.
Data-driven authentication coverage using TestNG, combining successful login validation with reusable negative scenarios for invalid credentials, locked-out users, and required-field validation.

Cross-Browser Execution & Results

The framework was designed to execute the same end-to-end test suite against both Chrome and Firefox, allowing browser-specific behavior to be validated without maintaining separate test implementations.
Browser selection is configuration-driven, while BaseTest initializes the appropriate WebDriver implementation. The complete suite was executed independently against both supported browsers.
The recorded validation results were:
Chrome — 27/27 passed, 0 failures, 0 skipped Firefox — 27/27 passed, 0 failures, 0 skipped
This validates not only the implemented business scenarios but also the framework reliability checks under the supported execution environments.

Reporting & Failure Evidence

The framework integrates ExtentReports to provide readable execution results alongside the standard Maven, Surefire, and TestNG outputs. Each execution creates a uniquely identified report directory so evidence from separate runs is not overwritten.
A custom TestNG listener records test outcomes and captures browser screenshots when failures occur. Screenshot evidence is linked to the generated report, making failed scenarios easier to investigate without reproducing the issue immediately.
Failure handling is designed defensively: screenshot or reporting problems do not prevent browser teardown, duplicate screenshot attempts are avoided, and driver cleanup remains part of the test lifecycle. Dedicated framework reliability tests validate these failure paths.
ExtentReports execution evidence from the expanded Selenium E2E suite, showing successful functional, negative-validation, cart, checkout, and framework-reliability test scenarios.
ExtentReports execution evidence from the expanded Selenium E2E suite, showing successful functional, negative-validation, cart, checkout, and framework-reliability test scenarios.

CI/CD & Cross-Browser Validation

The Selenium suite is integrated with GitHub Actions to provide repeatable automated validation outside the local development environment. The CI workflow executes the Maven/TestNG suite in a clean Linux runner and validates the framework independently of the developer workstation.
The workflow uses a browser matrix to execute the same test suite against Chrome and Firefox, providing cross-browser coverage without maintaining separate test implementations. Browser selection is handled through framework configuration, while the same Page Objects, test scenarios, assertions, and reporting infrastructure are reused across both executions.
The controlled CI execution completed successfully across both Chrome and Firefox. GitHub Actions executed each browser as an independent matrix job and generated separate test-result artifacts for both runs. This provides reproducible evidence that the automated suite executes successfully across the two supported browsers in a clean CI environment.
This CI layer turns the project from a locally executable Selenium suite into a repeatable automation pipeline that can validate changes on every repository update.
GitHub Actions cross-browser CI execution showing successful Selenium test runs on Chrome and Firefox, with separate test artifacts generated for each browser.
GitHub Actions cross-browser CI execution showing successful Selenium test runs on Chrome and Firefox, with separate test artifacts generated for each browser.

Framework Reliability & Failure Handling

A maintainable automation framework must handle failures reliably, not only execute successful functional scenarios. The framework therefore includes explicit safeguards around browser lifecycle management, configuration validation, reporting, and diagnostic evidence.
Browser setup and teardown are centralized in the base test layer. Configuration values such as browser selection and timeout settings are validated before execution, while teardown is designed to release the WebDriver session even when a test or supporting framework component fails.
Failed tests trigger automated screenshot capture to preserve diagnostic evidence. The reporting and cleanup mechanisms are also isolated so that a secondary failure—for example, a screenshot or reporting problem—does not leave the browser session running or prevent framework cleanup.
Dedicated framework-reliability tests validate these behaviors rather than assuming that the supporting infrastructure works correctly. The suite includes scenarios covering:
Browser cleanup when screenshot capture fails
Invalid timeout configuration before browser launch
Browser cleanup when reporting encounters a failure
Failure-evidence handling and session lifecycle behavior

Test Coverage & E2E Scenarios

The automated suite covers the core SauceDemo user journey together with negative and boundary scenarios. Rather than limiting coverage to isolated page checks, the tests exercise workflows across authentication, inventory, cart management, product details, and checkout.
The suite includes positive and negative authentication validation, product and inventory verification, cart operations, checkout validation, and complete purchase-flow scenarios. TestNG data providers are used where multiple input combinations need to exercise the same behavior without duplicating test logic.
Examples of automated coverage include valid and invalid login scenarios, locked-out user handling, product and inventory validation, adding and removing products from the cart, preserving cart state, required checkout-field validation, checkout cancellation behavior, and successful completion of the end-to-end checkout flow.
The combination of functional scenarios, negative validation, and framework-level reliability tests provides coverage of both application behavior and automation infrastructure.

Project Outcome

This project demonstrates the development of a maintainable Selenium E2E automation framework rather than a collection of isolated browser scripts. The framework separates test scenarios from page interaction logic, centralizes WebDriver and configuration management, and provides reusable synchronization, reporting, and failure-handling capabilities.
The automated suite covers core SauceDemo workflows across authentication, inventory, product, cart, and checkout functionality, including positive, negative, and validation scenarios. TestNG supports structured execution and data-driven coverage, while ExtentReports provides readable execution evidence and failure diagnostics.
The framework also includes dedicated reliability validation for its own supporting infrastructure. Browser cleanup, invalid configuration handling, screenshot failures, and reporting failures are explicitly tested to reduce the risk of automation infrastructure producing misleading or incomplete results.
GitHub Actions provides repeatable CI execution using a browser matrix. The suite has been successfully executed against both Chrome and Firefox, with separate execution artifacts generated for each browser.
Engineering Highlights
Built a reusable Page Object Model architecture for Selenium UI automation
Centralized browser lifecycle, configuration, waits, and common page interactions
Implemented positive, negative, data-driven, and end-to-end functional scenarios
Automated authentication, inventory, product, cart, and checkout workflows
Used explicit waits rather than relying on fixed delays for application synchronization
Added automated ExtentReports execution reporting
Captured diagnostic evidence for test failures
Added dedicated tests for framework reliability and cleanup behavior
Integrated the automation suite with GitHub Actions
Implemented CI matrix execution across Chrome and Firefox
Preserved browser-specific CI artifacts for execution review

Technologies & Skills

Java 17 · Selenium WebDriver · TestNG · Maven · Page Object Model · Data-Driven Testing · ExtentReports · GitHub Actions · CI/CD · Cross-Browser Testing · E2E Testing · UI Test Automation

Source Code

The complete framework—including Page Objects, automated test scenarios, configuration management, reporting integration, reliability tests, Maven/TestNG configuration, and GitHub Actions workflow—is available in the GitHub repository.
Like this project

Posted Oct 4, 2026

Built a maintainable Selenium E2E framework with Java, TestNG, Page Objects, reporting, failure handling, and Chrome/Firefox CI execution.