Comprehensive end-to-end UI test automation suite for the SauceDemo e-commerce application using Python and Playwright. Demonstrates production-ready test automation practices including authentication flows, shopping cart operations, checkout validation, and multi-user role testing with CI/CD integration.
- ✅ Complete E-Commerce Flow Testing - Login → Browse → Add to Cart → Checkout → Order Complete
- ✅ Multi-User Role Testing - Standard, Locked Out, Problem User, Performance Glitch User scenarios
- ✅ Form Validation Testing - Negative test cases for checkout field validation
- ✅ Cross-Browser Testing - Automated tests across Chromium, Firefox, and WebKit
- ✅ Reusable Test Fixtures - Pre-authenticated user sessions for efficient testing
- ✅ Helper Functions - Modular, maintainable test utilities
- ✅ CI/CD Integration - Automated test execution via GitHub Actions
- ✅ Centralized Configuration - Constants file for easy maintenance
- Language: Python 3.12
- Automation Framework: Playwright
- Test Framework: pytest
- CI/CD: GitHub Actions
- Package Manager: uv
python-playwright-saucedemo/
├── tests/
│ ├── helpers/
│ │ ├── constants.py # URLs, selectors, test data
│ │ ├── fixtures.py # Reusable authenticated user sessions
│ │ └── helpers.py # Common test operations (cart, checkout)
│ ├── conftest.py # Pytest configuration
│ ├── test_login.py # Authentication and login validation
│ ├── test_cart.py # Shopping cart operations
│ ├── test_checkout.py # Checkout flow and form validation
│ ├── test_inventory.py # Product display and inventory page
│ └── test_user_roles.py # Different user role behaviors
├── .github/
│ └── workflows/
│ └── playwright.yml # CI/CD configuration
├── pyproject.toml # Project dependencies
├── pytest.ini # Pytest configuration
└── README.md
- ✅ Valid user login
- ✅ Invalid credentials error handling
- ✅ Locked out user validation
- ✅ Problem user login (UI quirks)
- ✅ Performance glitch user login (slow loading)
- ✅ Add single item to cart
- ✅ Add multiple items to cart
- ✅ Remove item from cart
- ✅ Cart badge count updates
- ✅ Cart state persistence
- ✅ Complete end-to-end checkout
- ✅ First name validation (required field)
- ✅ Last name validation (required field)
- ✅ Zip code validation (required field)
- ✅ Checkout cancellation
- ✅ Order completion confirmation
- ✅ Product page loads for authenticated users
- ✅ Products display correctly
- ✅ Different user roles can access inventory
- Python 3.12+
- uv package manager
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/vernko/python-playwright-saucedemo.git
cd python-playwright-saucedemo
# Install dependencies
uv sync
# Install Playwright browsers
uv run playwright install# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_login.py -v
# Run specific test
uv run pytest tests/test_checkout.py::test_complete_checkout -v
# Run in headed mode (see browser)
uv run pytest --headed
# Run with HTML report
uv run pytest --html=report.html
# Run specific browser
uv run pytest --browser firefoxPre-authenticated user sessions for efficient test execution:
def test_add_to_cart(authenticated_page: Page):
# Page already logged in as standard_user
add_item_to_cart(authenticated_page)All URLs, selectors, and test data in constants.py for easy maintenance:
from tests.helpers.constants import LOGIN_URL, STANDARD_USERReusable operations for common workflows:
from tests.helpers.helpers import add_item_to_cart, navigate_to_checkoutTests run automatically on GitHub Actions for:
- Every push to
mainbranch - Every pull request to
mainbranch
Pipeline includes:
- Setup Python 3.12 environment
- Install dependencies with uv
- Install Playwright browsers
- Execute full test suite across Chromium, Firefox, WebKit
- Generate test reports
View test results in the Actions tab.
- End-to-End Testing - Complete user flows from login to order completion
- Negative Testing - Form validation and error handling
- Multi-User Testing - Different user roles and behaviors
- Test Fixtures - Reusable test setup and teardown
- Cross-Browser Testing - Multi-browser compatibility validation
- CI/CD Integration - Automated testing in deployment pipeline
- Maintainable Architecture - Helper functions, constants, and modular design
All tests pass consistently across:
- ✅ Chromium
- ✅ Firefox
- ✅ WebKit
Tests cover 5 major functional areas with 20+ test cases.