1. Installation
🔹 Prerequisites
🔹 Install Playwright
✅ This installs Chromium, Firefox, and WebKit engines for Playwright.
2. Configuration
🔹 Project Structure
-
tests/
→ contains test cases -
conftest.py
→ pytest fixtures (e.g., browser setup) -
requirements.txt
→ dependencies
🔹 requirements.txt
🔹 pytest.ini
3. First Test (Development)
Create tests/test_google.py
:
Run test:
-
--headed
→ shows browser UI -
Default is headless (faster)
4. Advanced Setup
🔹 Using Pytest Fixtures (Reusable Browsers)
Create conftest.py
:
Now tests/test_google.py
becomes:
5. Execution
🔹 Run All Tests
🔹 Run Specific Marker
🔹 Parallel Execution
6. Jenkins CI/CD Integration
🔹 Step 1: Install Jenkins
-
Download from https://www.jenkins.io/download/
-
Install plugins:
-
Git
-
HTML Publisher (to view reports)
-
🔹 Step 2: Jenkins Job
-
Create a Pipeline Job
-
Configure Git repo (with Playwright project)
-
Add build steps:
-
Post-build actions → Publish HTML report:
-
HTML directory:
.
-
Index page:
report.html
-
🔹 Jenkinsfile (Pipeline as Code)
Place this in your repo:
7. Scaling Up
-
Cross-browser execution:
-
Parallel test execution:
pytest -n auto
-
Cloud Testing: Integrate with BrowserStack/Sauce Labs
-
Reporting: Allure Reports (
pip install allure-pytest
) -
Dockerize your test framework for portability
8. Real-World Project Idea
📌 Automate an e-commerce site workflow with Playwright:
-
Search → Add to cart → Checkout → Validate order in DB
-
Cover UI + API + DB layers
-
Integrate with Jenkins for nightly regression runs
✅ In summary:
-
Install Python + Playwright
-
Set up virtual environment + pytest config
-
Write first test (
test_google.py
) -
Build framework with fixtures & POM
-
Run tests locally + in parallel
-
Integrate with Jenkins pipeline (CI/CD)
-
Scale with reporting, Docker, Cloud execution