Skip to content

ac0z/playwright-e2e-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

playwright-e2e-framework

Production-grade Playwright E2E test framework built for teams that need maintainable automation — not scripts that break when a developer changes a class name.

Covers full browser automation with parallel execution, Allure reporting, and CI/CD integration out of the box. Designed to be extended, not rewritten.


Features

  • Page Object Model architecture with a typed base class
  • Parallel execution across browsers via pytest-xdist
  • Allure reporting with automatic screenshot and trace attachment on failure
  • Playwright trace capture for every failed test (viewable in trace viewer)
  • Configuration via environment variables — no hardcoded values
  • Authenticated session fixture for tests that require login
  • Smoke / regression / flaky test marker system
  • GitHub Actions workflow: smoke on PR, cross-browser regression on merge

Architecture

playwright-e2e-framework/
├── .github/workflows/      # CI pipeline (smoke + cross-browser regression)
├── config/
│   └── settings.py         # Centralized config, reads from env vars
├── core/
│   └── browser.py          # Browser/context lifecycle management
├── pages/
│   ├── base_page.py        # Base POM class: interactions, assertions, utils
│   └── login_page.py       # Example page object
├── tests/
│   ├── conftest.py         # Fixtures: page, context, authenticated_page
│   └── test_login.py       # Example test class
├── utils/
│   └── helpers.py          # Retry logic, test data loader, name sanitizer
├── reports/                # Generated at runtime (gitignored)
├── pytest.ini              # Test discovery, markers, Allure config
└── requirements.txt

All browser and context management is handled in conftest.py. Page objects receive a Page object and do not interact with Playwright internals directly. Test failures automatically attach screenshots and trace files to the Allure report.


Requirements

  • Python 3.10+
  • pip

Setup

git clone https://github.com/ac0z/playwright-e2e-framework
cd playwright-e2e-framework
pip install -r requirements.txt
playwright install --with-deps chromium

Configure your target environment:

export BASE_URL=https://your-app.example.com
export TEST_USERNAME=testuser@example.com
export TEST_PASSWORD=yourpassword

Running Tests

# Smoke tests only
pytest -m smoke

# Full regression, 4 workers
pytest -m "not flaky" -n 4

# Specific browser
BROWSER=firefox pytest -m regression

# Headed mode for local debugging
HEADLESS=false pytest tests/test_login.py -v

Reports

Allure results are written to reports/allure-results/ by default.

# Serve the report locally (requires allure CLI)
allure serve reports/allure-results

In CI, the report is automatically published to GitHub Pages on merge to main.


CI Pipeline

Trigger Job Browsers
Pull request Smoke tests Chromium
Push to main/develop Regression Chromium, Firefox, WebKit
Nightly (02:00 UTC) Full regression Chromium, Firefox, WebKit

Failed runs upload screenshots and Playwright trace files as artifacts.


Adding a New Page Object

  1. Create pages/your_page.py extending BasePage
  2. Define locators as @property methods
  3. Define action methods using self.click(), self.fill(), etc.
  4. Add @allure.step() decorators to action methods
  5. Write tests in tests/test_your_feature.py

License

MIT

About

Production-grade Playwright E2E test framework with POM architecture, parallel execution, and CI/Allure integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages