Skip to content

Latest commit

Β 

History

History
126 lines (87 loc) Β· 3.6 KB

File metadata and controls

126 lines (87 loc) Β· 3.6 KB

πŸ§ͺ Playwright Automation Framework (Pytest + Allure)

This framework uses Playwright with Pytest for end-to-end testing and Allure for advanced reporting.


πŸ“¦ Prerequisites

Before running tests, ensure you have the following installed:

  • Python 3.8+
  • pytest
  • pytest-playwright
  • allure-pytest
  • Allure command-line (for report generation)
  • Playwright browsers (install via: playwright install)

πŸ› οΈ Setup Instructions

Create Virtual Environment python -m venv .venv Activate Virtual Environment Windows: .venv\Scripts\activate Install Dependencies pip install -r requirements.txt Install Playwright Browsers playwright install


πŸš€ Running Tests

You can run tests with different browsers and modes (headed/headless) using command-line options.

βœ… Run on Any Browser (Headed/Headless Mode) :

βœ… Run Tests on Chrome (Headed Mode)

pytest -s -v Testcases/test_base.py --mybrowser=firefox --alluredir=reports/allure-results

βœ… Run Tests on Chrome (Headless Mode)

pytest -s -v Testcases/test_base.py --mybrowser=chromium --headless --alluredir=reports/allure-results

βœ… Generate Trace headless mode only

pytest -s -v Testcases/test_login.py --mybrowser=chromium --headless --alluredir=reports/allure-results --tracing on

Parallel test execution

pytest -n 3 -s -v Testcases/test_base.py --mybrowser=chromium --headless --alluredir=reports/allure-results

with Trace

pytest -n auto -s -v --mybrowser=chromium --headless --alluredir=reports/allure-results --tracing on

Trace viewer-paralell test execution with HTml report

pytest -s -v -n auto --mybrowser=chromium --headless --html=report.html --tracing on

View Trace

After running tests with tracing enabled, you can view the trace files in the 'trace' directory.

Open the trace viewer using the following command:

playwright show-trace trace/trace.zip playwright show-trace traces/test_search_iphone.zip


πŸ“Š Generating Reports

Generate and Open Allure Report allure serve reports/allure-results


##πŸ”§ Configuration Browser Options

--mybrowser: Choose browser (chrome, firefox, webkit)

--headed: Run in headed mode (true/false)

Example Configuration in pytest.ini

ini[pytest] addopts = -v -s --alluredir=reports/allure-results testpaths = Testcases


πŸ“ playwright_framework

playwright_framework/
β”‚
β”œβ”€β”€ .venv/
β”œβ”€β”€ base/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ base_page.py
β”‚   └── playwright_factory.py
β”œβ”€β”€ logs/
β”‚   └── test_log.log
β”œβ”€β”€ page_objects/
β”‚   └── __init__.py
β”œβ”€β”€ reports/
β”‚   β”œβ”€β”€ allure-results/
β”‚   └── allure-report/
β”œβ”€β”€ screenshots/
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_base.py
β”‚   └── test_search_thar.py
β”œβ”€β”€ utilities/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ logger.py
β”‚   └── screenshot.py
β”‚
β”œβ”€β”€ conftest.py
β”œβ”€β”€ pytest.ini
β”œβ”€β”€ README.md
└── requirements.txt