Skip to content

kunal-sikka/playwright-python-hybrid-automation-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Playwright Python Hybrid Automation Framework (UI + API + BDD)

CI Python Playwright Pytest BDD Allure Allure Report


πŸ“Œ Overview

This is a production-style hybrid automation framework built using Playwright (Python), Pytest, and BDD.

It demonstrates a modern QA strategy where:

  • API is used for fast test setup
  • UI is used for end-to-end validation
  • BDD is used for business-readable scenarios

πŸ‘‰ Designed to reflect how real-world QA teams build scalable and reliable automation systems


⚑ Key Highlights

  • Hybrid testing (API + UI validation)
  • Clean Page Object Model (POM) architecture
  • Dedicated API client layer (Auth, Orders, Products)
  • Reusable workflow layer for E2E setup
  • BDD implementation using pytest-bdd
  • Secure credential handling (.env + GitHub Secrets)
  • Automatic failure screenshots
  • Allure reporting with readable steps
  • CI/CD pipeline with GitHub Actions
  • Retry mechanism for flaky network/API calls

πŸ›  Tech Stack

  • Python 3.12
  • Playwright (UI + API)
  • Pytest
  • pytest-bdd
  • Allure Reports
  • GitHub Actions

🧠 Architecture Approach

The framework follows separation of concerns:

  • pages/ β†’ UI interactions (POM)
  • api/ β†’ Backend API layer
  • workflows/ β†’ Hybrid orchestration logic
  • tests/ β†’ UI, API, and E2E tests
  • features/ β†’ BDD scenarios

πŸ‘‰ Result: clean, maintainable, scalable automation design


πŸ“ Project Structure

.
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ assertions.py          # API response validations
β”‚   β”œβ”€β”€ auth_client.py         # Authentication API client
β”‚   β”œβ”€β”€ orders_client.py       # Orders API client
β”‚   β”œβ”€β”€ products_client.py     # Products API client
β”‚   └── workflows.py           # Hybrid API workflows
β”‚
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ environments.json      # Environment configs (QA, etc.)
β”‚   β”œβ”€β”€ settings.py            # Config loader & models
β”‚   └── test_data.py           # Static test data
β”‚
β”œβ”€β”€ data/
β”‚   └── credentials.example.json   # Sample credentials structure
β”‚
β”œβ”€β”€ docs/
β”‚   └── QA_Test_Suite_Hybrid_Playwright_Framework.xlsx   # Test documentation
β”‚
β”œβ”€β”€ features/                  # BDD feature files
β”‚   β”œβ”€β”€ api_order.feature
β”‚   β”œβ”€β”€ cart.feature
β”‚   β”œβ”€β”€ checkout.feature
β”‚   β”œβ”€β”€ hybrid_order.feature
β”‚   β”œβ”€β”€ login.feature
β”‚   └── order_history.feature
β”‚
β”œβ”€β”€ pages/                     # Page Object Model (UI)
β”‚   β”œβ”€β”€ cart_page.py
β”‚   β”œβ”€β”€ checkout_page.py
β”‚   β”œβ”€β”€ confirmation_page.py
β”‚   β”œβ”€β”€ dashboard_page.py
β”‚   β”œβ”€β”€ login_page.py
β”‚   β”œβ”€β”€ order_details_page.py
β”‚   β”œβ”€β”€ order_history_page.py
β”‚   └── register_page.py
β”‚
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ step_definitions/      # BDD step implementations
β”‚   β”‚   β”œβ”€β”€ test_api_order_steps.py
β”‚   β”‚   β”œβ”€β”€ test_cart_steps.py
β”‚   β”‚   β”œβ”€β”€ test_checkout_steps.py
β”‚   β”‚   β”œβ”€β”€ test_hybrid_order_steps.py
β”‚   β”‚   β”œβ”€β”€ test_login_steps.py
β”‚   β”‚   └── test_order_history_steps.py
β”‚   β”‚
β”‚   β”œβ”€β”€ test_api_auth.py
β”‚   β”œβ”€β”€ test_api_order_flow.py
β”‚   β”œβ”€β”€ test_api_order_negative.py
β”‚   β”œβ”€β”€ test_api_product_flow.py
β”‚   β”œβ”€β”€ test_api_security.py
β”‚   β”œβ”€β”€ test_cart_flow.py
β”‚   β”œβ”€β”€ test_checkout_flow.py
β”‚   β”œβ”€β”€ test_e2e_flow.py
β”‚   β”œβ”€β”€ test_login_flow.py
β”‚   β”œβ”€β”€ test_order_flow.py
β”‚   └── test_registration_flow.py
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ credentials.py         # Env-based credential handling
β”‚   β”œβ”€β”€ product_factory.py     # Test data generator
β”‚   └── user_factory.py        # User data factory
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── tests.yml          # CI pipeline
β”‚
β”œβ”€β”€ conftest.py                # Pytest fixtures
β”œβ”€β”€ pytest.ini                 # Pytest configuration
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ README.md
β”œβ”€β”€ .gitignore

βš™οΈ Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install

πŸ” Environment Setup

Create a .env file in the root:

TEST_EMAIL=your-email@example.com
TEST_PASSWORD=your-password
  • .env is not committed for security
  • GitHub CI uses repository secrets

▢️ Running Tests

pytest
pytest --env=qa
pytest -m api
pytest -m ui
pytest -m e2e
pytest -m bdd
pytest --browser_name=firefox
pytest --headed

πŸ” BDD Coverage

BDD scenarios validate business flows such as:

  • Login
  • Add to cart
  • Checkout
  • API order creation
  • API-created order visible in UI
  • Order history validation

Example:

Feature: Login

  Scenario: User logs in with valid credentials
    Given login user is on the login page
    When login user logs in with valid credentials
    Then login user should see the products page

πŸ”„ CI/CD Pipeline

  • Runs on every push & pull request
  • Executes full test suite
  • Uses secure GitHub Secrets

Uploads:

  • Allure results
  • Failure screenshots

Includes retry for flaky tests


πŸ“Š Reporting

Allure report provides:

  • Feature-based grouping
  • Step-level execution logs
  • Business-readable test flows

To generate locally:

pytest --alluredir=allure-results
allure serve allure-results

πŸ”₯ Flagship Hybrid Flow

This project demonstrates a real-world high-value scenario:

  1. Generate login token via API
  2. Create order via API
  3. Login via UI
  4. Navigate to order history
  5. Validate API-created order in UI

πŸ‘‰ Reduces UI dependency and speeds up E2E testing significantly


πŸ€– AI-Assisted Development

This framework leverages tools like Codex and Claude to enhance productivity:

  • Accelerated framework setup and refactoring
  • Improved code quality and structure
  • Faster debugging and issue resolution

πŸ‘‰ AI was used as a productivity accelerator, while all architecture, validation logic, and QA decisions were designed and verified manually


πŸ’Ό Why This Project Matters

This project showcases:

  • Real-world QA automation architecture
  • Hybrid testing strategy (API + UI)
  • Scalable and maintainable design
  • CI/CD readiness
  • Strong QA engineering practices

πŸ‘‰ Built to reflect skills directly applicable to production environments and client projects


πŸ“¬ Contact

πŸ’Ό Hire me on Upwork: Click here to view my Upwork Profile & discuss your project

About

Production-ready Hybrid Automation Framework using Playwright (Python), Pytest, and Behave (BDD). Covers scalable UI/API E2E testing, POM architecture, and CI/CD via GitHub Actions. πŸ’Ό Available for freelance QA Automation roles on Upwork!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors