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.
- 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.
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
- Python 3.9+
- Google Chrome (latest)
- Git
git clone https://github.com/ng10op/SoftwareTestingCaseStudy.git
cd SoftwareTestingCaseStudyWindows:
python -m venv venv
venv\Scripts\activateMac/Linux:
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtTests 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
--headlessflag to enable it.
Headed (default):
pytestHeadless:
pytest --headlessOutputs generated: reports/report.html, reports/logs/test.log, reports/SauceDemo_Test_Report.pdf.
Validates critical path: Login → Add to Cart → Checkout → Finish.
Headed (default):
pytest -m smokeHeadless:
pytest -m smoke --headlessValidates negative scenarios, boundaries, and CSV-driven data.
Headed (default):
pytest -m regressionHeadless:
pytest -m regression --headlessFor 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.batDetailed reports are generated at reports/report.html, including execution summary, duration, and failure trace details.
Detailed PDF reports are generated at reports/SauceDemo_Test_Report.pdf, including execution summary, duration, and failure trace details and failure screenshots.
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-managerhandles driver binaries automatically — no manual download ofchromedriver.exeis required.