How farhaanshareef/playwrightautomationframework works
Project Type and Purpose
• This is an open-source Python-based web-automation framework using Playwright and pytest.
• It’s designed for end-to-end testing, offering cross-browser support, parallel execution, and HTML reporting.
Main Components and Their Roles
a. Test Runner (pytest)
• Entry point: pytest CLI
• Orchestrates test discovery (in test/) and execution.
b. **Test Suites (test/*.py)**
• Individual test files (e.g., test_form_submission.py) using fixtures from conftest.py.
c. Page Object Layer (pageObject/)
• Implements the Page Object Model (base_page.py, form_page.py)
• Encapsulates page interactions via Playwright API.
d. Configuration Module (config/config.py)
• Holds environment settings, timeouts, URLs, browser flags.
e. Utilities (utils/logger.py)
• Centralized logging for debug info, writing to logs/.
f. Playwright Engine & Browsers
• External dependency managing Chromium, Firefox, WebKit.
• Configured via playwright-config/playwright_config.json.py.
g. Reporting Module
• pytest-html plugin generates reports/report.html.
• Static assets in reports/assets/ and assets/style.css.
h. Artifacts
• logs/ for runtime logs
• reports/ for HTML reports & screenshots
Relationships and Data Flow
1. pytest launches → 2. Test Suites
2. Test Suites call → Page Objects
3. Page Objects use → Playwright Engine (via Python API)
4. Playwright Engine drives → Browser Instances → interacts with → Web App Under Test
5. Throughout execution, Utilities capture logs → write to /logs
6. On completion/failure, pytest-html plugin assembles → HTML Report in /reports
7. Configuration Module feeds parameters into Test Runner & Page Objects
Architectural Patterns and Design Principles
• Page Object Model: decouples test logic from UI specifics.
• Modular Structure: clearly separated layers—tests, page objects, config, utils.
• Plugin-Based Reporting: leverages pytest hooks for extensibility.
• Parallel Execution: concurrency handled by pytest-xdist or Playwright’s built-in parallelism.