Playwright + Pytest + Page Object Model for SauceDemo
π Overview
This project is a Playwright UI automation framework in Python designed to test the SauceDemo application using:
Playwright (Python)
Pytest
Page Object Model (POM)
Pytest fixtures
Allure reporting
GitHub Actions CI pipeline
It demonstrates a clean, scalable, interview-ready automation architecture suitable for professional SDET portfolios.
π Project Structure playwright-saucedemo-python/ β βββ pages/ β βββ base_page.py β βββ login_page.py β βββ inventory_page.py β βββ cart_page.py β βββ checkout_page.py β βββ checkout_overview_page.py β βββ tests/ β βββ test_login.py β βββ test_checkout_flow.py β βββ conftest.py βββ pytest.ini βββ requirements.txt βββ README.md
π§ͺ Features β Playwright Python
Browser automation using Chromium, Firefox, and WebKit
Native trace viewer
Headless/headed mode
Slow-motion runs (--slowmo)
β Pytest Test Framework
Fixtures (page, login_page)
Test parametrization
Test grouping and tagging
β Page Object Model (POM)
Each page is represented as a class
Clean separation of locators, actions, and assertions
β Full E2E Flow Included
Login
Add item to cart
Checkout
Validate order success
β Allure Reporting
Beautiful report UI + dashboards
Auto-attach traces, screenshots, steps
GitHub Actions-compatible
πββοΈ Getting Started 1οΈβ£ Create virtual environment python -m venv .venv .venv\Scripts\activate
2οΈβ£ Install dependencies pip install -r requirements.txt
3οΈβ£ Install Playwright browsers playwright install
βΆ Running Tests Headed + slow motion (recommended) pytest --headed --slowmo 500
Normal run pytest
π Allure Reporting Install Allure (Windows)
Download Allure from: https://github.com/allure-framework/allure2/releases
Unzip and add allure/bin to your system PATH.
Verify:
allure --version
Run tests with Allure pytest --alluredir=allure-results
Generate report locally allure serve allure-results
π GitHub Actions CI (Playwright + Pytest + Allure)
This project includes a ready-to-run GitHub Actions workflow that:
Installs Python
Installs Playwright browsers
Runs tests
Uploads Allure results as an artifact
Runs tests on every push + PR
𧬠Roadmap / Future Enhancements
Add reporting screenshots & videos
Add Docker support
Extend POM to cover all SauceDemo pages
Add API + UI combo tests
π License
This project is licensed under the MIT License.