A robust, scalable Python template for automated testing of both web UIs and APIs. Built with Playwright, Requests, and Pytest, it enables seamless end-to-end, UI, and API test automation with environment-based configuration and rich reporting.
-
Copy or Fork This Repository
- Use this repo as a starting point for your own automation project.
-
Configuration
- Copy
config/template.jsontoconfig/dev.json,config/qa.json, etc. and fill in your environment-specific values. - Add or modify config keys as needed for your project.
- Copy
-
API Client
src/api/client.pycontains example methods and endpoints. Replace or extend these with your own API endpoints.- Use the provided structure for authentication and session management
-
UI Page Objects
src/ui/pages/base_page.pyis a generic base class for your page objects.src/ui/pages/login_page.pyandsrc/ui/pages/inventory_page.pyare examples. Replace selectors and methods with those for your application, or add new page objects as needed.
-
Utilities
src/utils/config.pyloads config based on the ENV variable. Extend as needed.src/utils/logger.pyprovides a logger. Change log level or add file logging as needed.
-
Writing Tests
- Place new API tests in
tests/api/, UI tests intests/ui/, and hybrid tests intests/e2e/. - Use fixtures from
conftest.pyfor config and API client access. - Use Playwright’s page object model for UI automation.
- Place new API tests in
-
Remove Example Code
- Remove or replace example endpoints, selectors, and test cases with your own.
- Hybrid Testing: Automate both UI (web) and API workflows, or combine them for end-to-end scenarios.
- Playwright Integration: Fast, reliable browser automation for modern web apps.
- API Automation: Use Requests for flexible, powerful API testing.
- Configurable Environments: Easily switch between environments (dev, qa, etc.) using JSON config files.
- Parallel Execution: Speed up test runs with pytest-xdist.
- Allure Reporting: Generate beautiful, interactive test reports.
- Extensible Structure: Modular codebase for easy maintenance and scaling.
- Python 3.11+
- Pytest (test runner)
- Playwright (UI automation)
- Requests (API automation)
- pytest-xdist (parallel test execution)
- Allure-pytest (reporting)
- jsonschema (API response validation)
├── src/ # Framework source code
│ ├── api/ # API client, helpers (replace with your endpoints)
│ ├── ui/ # UI page objects, helpers (replace with your pages)
│ ├── utils/ # Config, logger, utilities
│ └── __init__.py
├── tests/ # Test cases (add your own)
│ ├── api/ # API tests
│ ├── ui/ # UI tests
│ └── e2e/ # End-to-end (hybrid) tests
├── config/ # Environment configs (copy template.json)
├── scripts/ # Setup scripts
│ └── setup_playwright.ps1
├── conftest.py # Pytest fixtures (config, API client, etc.)
├── requirements.txt # Python dependencies
├── pytest.ini # Pytest config & markers
└── README.md # Project documentation
git clone <REPO_URL>
cd hybrid-automationpython -m venv .venv
# Windows:
. .venv/Scripts/activate
# macOS/Linux:
source .venv/bin/activatepip install -r requirements.txt
python -m playwright installOr use the provided PowerShell script (Windows):
scripts/setup_playwright.ps1Set the environment variable to select config (e.g., dev, qa):
# Windows:
set ENV=dev
# macOS/Linux:
export ENV=dev- Smoke tests:
pytest -m smoke -n auto --alluredir=allure-results
- UI tests:
pytest -m ui --headed
- API tests:
pytest -m api
- E2E tests:
pytest -m e2e
allure serve allure-results- Copy
config/template.jsonto your environment (e.g.,dev.json,qa.json) and fill in values. - Sensitive data (tokens, etc.) can be set via environment variables or config files.
Defined in pytest.ini:
smoke: Basic checksui: UI testsapi: API testse2e: End-to-end (hybrid) tests
- Fork the repo and create a feature branch.
- Add/modify tests or framework code.
- Ensure all tests pass and code is linted.
- Submit a pull request with a clear description.
For questions or issues, open an issue on GitHub or contact the maintainer.