A professional-grade test automation framework built with Playwright and Python, following industry best practices and design patterns.
playwright-python-framework/
│
├── pages/                      # Page Object Models
│   ├── base_page.py           # Base page with common methods
│   └── automation_page.py     # Specific page objects
│
├── tests/                     # Test cases
│   ├── conftest.py           # Pytest fixtures and hooks
│   ├── test_smoke.py         # Smoke tests
│   └── test_regression.py    # Regression tests
│
├── utils/                     # Utilities and helpers
│   ├── config_reader.py      # Configuration management
│   ├── logger.py             # Custom logging
│   ├── test_data.py          # Test data management
│   └── helpers.py            # Helper functions
│
├── test_data/                # Test data files
│   ├── test_users.json
│   └── test_scenarios.yaml
│
├── reports/                  # Test reports (auto-generated)
├── logs/                     # Log files (auto-generated)
├── pytest.ini               # Pytest configuration
├── requirements.txt         # Python dependencies
└── .env                     # Environment variables
- Page Object Model (POM): Clean separation of test logic and page elements
- Pytest Framework: Powerful testing with fixtures and parametrization
- Multi-Browser Support: Chrome, Firefox, Safari, Edge
- Parallel Execution: Run tests in parallel with pytest-xdist
- Smart Waits: Auto-waiting for elements with custom timeout handling
- Comprehensive Reporting: Allure reports, HTML reports, screenshots, videos
- CI/CD Ready: GitHub Actions workflow included
- Data-Driven Testing: JSON, YAML, Excel support
- Logging: Detailed logging for debugging
- Rerun Failed Tests: Automatic retry on failures
- Type Hints: Full type annotation for better IDE support
- Python 3.10 or higher
- pip package manager
- Clone the repository
git clone <repository-url>
cd "SDET playwright python"- Create virtual environment
python -m venv venv
.\venv\Scripts\activate  # Windows- Install dependencies
pip install -r requirements.txt
playwright install- Configure environment
cp .env.example .env
# Edit .env with your configurationpytestpytest tests/test_smoke.pypytest -m smoke           # Smoke tests only
pytest -m regression      # Regression tests only
pytest -m critical        # Critical tests onlypytest -n 4              # Run with 4 workers
pytest -n auto           # Auto-detect number of CPUspytest --browser chromium
pytest --browser firefox
pytest --browser webkitpytest --headedpytest --alluredir=reports/allure-results
allure serve reports/allure-resultsAfter test execution, find the report at:
reports/html/report.html
Generate and view Allure report:
allure serve reports/allure-resultsDetailed logs are available at:
logs/test_execution.log
Configure pytest behavior, markers, and logging.
Set environment-specific variables:
- BASE_URL: Application URL
- BROWSER: Default browser (chromium/firefox/webkit)
- HEADLESS: Run in headless mode (true/false)
- DEFAULT_TIMEOUT: Default timeout in milliseconds
import pytest
from pages.automation_page import AutomationPage
@pytest.mark.smoke
def test_example(page):
    automation_page = AutomationPage(page)
    automation_page.navigate()
    automation_page.verify_page_loaded()- One assertion per test method (when possible)
- Use descriptive test names
- Keep tests independent
- Use Page Object Model
- Implement proper waits
- Clean test data after execution
- Use markers for test organization
- Maintain test data separately
GitHub Actions workflow is included in .github/workflows/test.yml
Push to repository to trigger automated tests on:
- Push to main/develop branches
- Pull requests
- Scheduled runs (nightly)
For issues and questions, please create an issue in the repository.
MIT License