A minimal, clean Python test automation framework built with pytest and Playwright, focused on:
- deterministic local execution
- fast feedback
- enforced code quality via pre-commit hooks
This repository is intentionally kept simple as a foundation for further expansion.
- Python 3.10+ (tested locally with a virtual environment)
- Git
- Node.js (required by Playwright)
├── tests/
│ ├── conftest.py # pytest + Playwright fixtures and failure artifacts
│ └── test_smoke.py # example smoke test
├── artifacts/
│ ├── screenshots/ # screenshots captured on test failure
│ └── traces/ # Playwright traces (optional)
├── reports/ # test reports (if enabled)
├── .pre-commit-config.yaml
├── pyproject.toml
└── README.md
python -m venv .venv
source .venv/bin/activate # Linux / macOS
.venv\Scripts\activate # Windows PowerShell
pip install -r requirements.txt
Install Playwright browsers:
python -m playwright install
pytest
pytest tests/test_smoke.py
pytest --headed
pytest --browser chromium
pytest --browser firefox
pytest --browser webkit
pytest --slowmo 200
This project supports running tests in parallel using pytest-xdist.
pip install pytest-xdist
Run with an automatic number of workers:
pytest -n auto
Run with a fixed number of workers (example: 4):
pytest -n 4
On test failure, the framework automatically captures:
Playwright trace (ZIP, optional)
Artifacts are stored under:
artifacts/
├── screenshots/
└── traces/
PW_TRACE=true pytest
Traces are saved only when a test fails.
This project uses pre-commit to enforce code quality checks before each commit.
Ruff – fast Python linting with auto-fixes
Ruff Format – consistent code formatting
Mypy – static type checking (ignores missing third-party stubs)
pip install pre-commit
pre-commit install
pre-commit run --all-files
After setup, hooks run automatically on every git commit. If a hook modifies files or fails, re-stage the changes and commit again.
| Parameter | Description |
|---|---|
| BROWSER | Playwright browser engine (chromium, firefox, webkit) |
| SUITE | Test suite to execute (smoke, e2e, all) |
| PW_TRACE | Enable Playwright tracing on failure |
| SLOWMO | Slow down Playwright actions (milliseconds) |
pytest -m smoke
BROWSER=chromium PW_TRACE=true pytest -m e2e
Tests are executed via Jenkins parameterized builds using the provided Jenkinsfile.
Artifacts such as Playwright traces and test reports are automatically archived.
-
All paths are resolved relative to the repository root
-
Artifacts are created only for failed tests
-
The framework is intentionally minimal and designed to evolve incrementally