Skip to content

ng10op/SoftwareTestingCaseStudy

Repository files navigation

SauceDemo: Selenium Automation Framework Case Study

Overview

This project implements a reusable Selenium automation testing framework for the SauceDemo web application as part of a Software Testing Lab case study.

The framework validates functional requirements FR01 – FR16 using a robust, modular architecture designed for scalability and maintainability.


Features

  • Architecture: Page Object Model (POM) for clean separation of concerns.
  • Waits: Explicit Wait strategy (no hard-coded time.sleep).
  • Data-Driven: CSV-based testing for login scenarios.
  • Execution: Marker-based execution (Smoke vs. Regression).
  • Reporting: Automatic HTML and PDF report generation and detailed execution logging.
  • Failure Handling: Automatic screenshot capture on test failure.
  • Driver Management: Automatic ChromeDriver setup via webdriver-manager.

Project Structure

SauceDemo_Lab/
│
├── pages/                  # Page Object Classes
│   ├── base_page.py
│   ├── login_page.py
│   ├── inventory_page.py
│   └── checkout_page.py
│
├── tests/                  # Test Suites & Configurations
│   ├── conftest.py
│   └── test_saucedemo.py
│
├── testdata/               # External Data Files
│   └── login_data.csv
│
├── reports/                # Output Artifacts
│   ├── logs/
│   └── screenshots/
│
├── run_allTests.bat                # Runs full test suite (headed)
├── run_allTests_headless.bat       # Runs full test suite (headless)
├── run_regressionTests_headless.bat # Runs regression tests (headless)
├── run_smokeTests_headless.bat      # Runs smoke tests (headless)
├── pytest.ini              # PyTest Configuration & Markers
├── requirements.txt        # Project Dependencies
├── .gitignore
└── README.md

Prerequisites

  • Python 3.9+
  • Google Chrome (latest)
  • Git

Getting Started

1. Clone Repository

git clone https://github.com/ng10op/SoftwareTestingCaseStudy.git
cd SoftwareTestingCaseStudy

2. Create and Activate Virtual Environment

Windows:

python -m venv venv
venv\Scripts\activate

Mac/Linux:

python3 -m venv venv
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

Running the Automation Tests

Tests can be run in two modes:

  • Headed mode — opens a visible Chrome browser window (default).
  • Headless mode — runs Chrome in the background with no UI, ideal for CI/CD pipelines. Pass the --headless flag to enable it.

Run Complete Test Suite

Headed (default):

pytest

Headless:

pytest --headless

Outputs generated: reports/report.html, reports/logs/test.log, reports/SauceDemo_Test_Report.pdf.


Run Smoke Tests Only

Validates critical path: Login → Add to Cart → Checkout → Finish.

Headed (default):

pytest -m smoke

Headless:

pytest -m smoke --headless

Run Regression Tests Only

Validates negative scenarios, boundaries, and CSV-driven data.

Headed (default):

pytest -m regression

Headless:

pytest -m regression --headless

Batch File Shortcuts (Windows)

For convenience, four .bat files are provided in the project root to run tests without manually typing commands:

Batch File Mode Scope
run_allTests.bat Headed Full test suite
run_allTests_headless.bat Headless Full test suite
run_smokeTests_headless.bat Headless Smoke tests only
run_regressionTests_headless.bat Headless Regression tests only

Simply double-click the desired .bat file in File Explorer, or run it from the terminal:

run_allTests.bat
run_allTests_headless.bat
run_smokeTests_headless.bat
run_regressionTests_headless.bat

Reporting

HTML Reports

Detailed reports are generated at reports/report.html, including execution summary, duration, and failure trace details.

PDF Reports

Detailed PDF reports are generated at reports/SauceDemo_Test_Report.pdf, including execution summary, duration, and failure trace details and failure screenshots.

Execution Logs

Found at reports/logs/test.log. Logs follow this format:

RUNNING REQUIREMENT: FR14
STATUS: test_fr14_postal_code_boundary FAILED
Screenshot saved: reports/screenshots/test_fr14_postal_code_boundary.png

Note: webdriver-manager handles driver binaries automatically — no manual download of chromedriver.exe is required.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors