This is a comprehensive test automation framework built with Playwright for Python, designed to test the AutomationExercise web application. The framework follows the Page Object Model (POM) design pattern and implements component-based architecture for better code reusability and maintainability.
- Page Object Model (POM): Clean separation of page logic and test code
- Component-Based Architecture: Reusable UI components for common elements
- Data-Driven Testing: YAML-based test data management
- Modular Structure: Organized test suites for different functionality areas
- Pytest Integration: Leverages pytest fixtures and plugins for enhanced testing capabilities
- Cross-Browser Support: Chromium browser support via Playwright (easily extensible to Firefox and WebKit)
- Python: 3.10 or higher
- Operating System: Windows, macOS, or GNU/Linux
- Dependencies: Listed in
requirements.txt
git clone https://github.com/Geradot/playwright-python.git
cd playwright-pythonpython -m venv .venvWindows PowerShell:
.\.venv\Scripts\Activate.ps1Windows Command Prompt:
.venv\Scripts\activate.batLinux/macOS:
source .venv/bin/activatepip install -r requirements.txtplaywright install chromiumOr install all browsers:
playwright installpytestpytest tests/test_register_and_login.pypytest -vv -s --tb="short"pytest --headedpytest --browser chromium
pytest --browser firefox
pytest --browser webkitpytest -n autopytest --html=report.html --self-contained-htmlpytest -k "test_name"pytest --screenshot onpytest --video on- test_register_and_login.py - User registration and authentication tests
- test_products_and_cart.py - Product browsing and shopping cart tests
- test_other.py - Miscellaneous functionality tests
The framework uses pytest fixtures for configuration:
- base_url: Configured in
config/conftest.py(default: https://automationexercise.com) - Browser context: Session-scoped browser context for efficient test execution
- Page fixture: Function-scoped page instances for test isolation
Test data is managed through YAML files in the data/ directory and loaded via the data_loader utility. This approach provides:
- Easy data maintenance
- Separation of test logic and test data