This Python-based Web Automation Framework is built with Selenium 4, pytest, and a modern Page Object Model (POM) structure. It follows industry best practices for maintainability, CI/CD readiness, and clear reporting — including auto-screenshots on failure, HTML/Allure reports, and multi-environment configuration.
selenium_web_automation_framework/
│
├── config/
│ ├── config.yaml # Environment-specific URLs & waits
│ └── config_reader.py # YAML parser (auto-detects default env)
│
├── logs/ # Rotating logs created per run
│ └── test.log
│
├── reports/ # HTML / Allure reports
│ └── report.html
│
├── screenshots/ # Captured automatically on failures
│
├── src/
│ ├── base/
│ │ └── base_driver.py # Core WebDriver helpers
│ ├── pages/ # Page Object Model
│ │ └── login_page.py
│ └── utilities/ # Reusable helpers (logger, data utils)
│ ├── logger.py
│ ├── read_data.py
│ └── capture_screenshot.py
│
├── testCases/
│ ├── test_login.py
│ └── test_example.py
│
├── TestData/
│ └── data.xlsx
│
├── ci/
│ └── ci_config.yml # Example GitHub Actions workflow
│
├── conftest.py # Fixtures, env handling, screenshots on failure
├── pytest.ini # Pytest settings (reports, markers, env)
├── requirements.txt
└── README.md
| Area | Description |
|---|---|
| Driver Management | Uses Selenium Manager (no webdriver-manager dependency). |
| Cross-Environment Config | config.yaml defines test, staging, etc. |
| Screenshots on Failure | Auto-captured in screenshots/ and embedded in the HTML report. |
| Logging | Centralized rotating logs (logs/test.log). |
| HTML & Allure Reports | pytest-html + optional Allure for trend analytics. |
| Parallel Execution | pytest-xdist (-n auto). |
| CI Integration | Ready for GitHub Actions / Jenkins pipelines. |
| Data-Driven Testing | Read data from Excel or CSV via pandas / openpyxl. |
Windows (PowerShell)
python -m venv .venv
.venv\Scripts\Activate.ps1macOS/Linux
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtpytestpytest --env test
pytest --env stagingpytest -n auto --env=testpytest -m smoke --env=test -v
pytest -m regression --env=staging --maxfail=1After execution:
- HTML Report →
reports/report.html - Screenshots →
screenshots/(auto-captured on failure) - Logs →
logs/test.log
Example:
pytest --env=test --html=reports/report.html --self-contained-htmlEach failed test will show a screenshot preview and a link to the PNG file in the report.
default: test
environments:
test:
url: "https://example-test.com"
implicit_wait: 5
explicit_wait: 15
staging:
url: "https://example-staging.com"
implicit_wait: 5
explicit_wait: 15default: used if--envnot specified.- Accessed dynamically via
read_config().
[pytest]
addopts = -n auto --env=test --html=reports/report.html --self-contained-html --maxfail=3
log_cli = true
log_cli_level = INFO
log_file = logs/test.log
log_file_level = INFO
testpaths = testCases
markers =
smoke: quick tests to verify the core functionality
regression: comprehensive tests for the entire application.github/workflows/ui-tests.yml
name: UI Tests
on: [push, pull_request]
jobs:
ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -r requirements.txt
- name: Run headless tests
env:
HEADLESS: "true"
run: pytest -n auto --env=test
- name: Upload HTML report
if: always()
uses: actions/upload-artifact@v4
with:
name: pytest-html
path: reports/report.html- ✅ Page Object Model (POM) structure for maintainability
- ✅ Environment-driven setup via
config.yaml - ✅ Screenshots embedded automatically in HTML report
- ✅ Parallel test execution and clean teardown
- ✅ Fully CI/CD ready
- ✅ Easy to extend for API testing or mobile automation
This project is open-sourced for educational and demonstration purposes.