Prerequisites
Before you begin, ensure you have the following installed:Python 3.11+
Required for running pytest and Playwright
pip
Python package manager (included with Python)
Git
For cloning the repository
Terminal/Command Line
To run commands and tests
Verify Python Installation
Check your Python version:Installation Steps
Create a Virtual Environment (Recommended)
Using a virtual environment keeps your project dependencies isolated:You’ll see
(venv) in your terminal prompt when the virtual environment is active.Install Python Dependencies
Install all required packages from
requirements.txt:Installed Packages
Therequirements.txt includes:requirements.txt
Package Details
Package Details
- pytest - Modern Python testing framework with powerful features
- pytest-html - Generates beautiful HTML test reports
- pytest-playwright - Pytest plugin for Playwright integration
- playwright - Browser automation library supporting Chromium, Firefox, and WebKit
- python-dotenv - Loads environment variables from
.envfiles
Install Playwright Browsers
Playwright requires browser binaries to be installed separately:This downloads:
- Chromium
- Firefox
- WebKit (Safari engine)
The
--with-deps flag installs system dependencies required on Linux. On macOS and Windows, you can omit this flag: python -m playwright installInstall Specific Browsers Only
To save disk space, install only what you need:Project Structure
After installation, your project structure looks like this:Configuration
Test Fixtures
The project uses pytest fixtures defined intests/conftest.py:8 for test data management:
Environment Variables Setup
Create a.env file in the project root for sensitive credentials:
.env
Test Data Files
Store test data in JSON format attestData/users.json:
testData/users.json
users fixture:
CI/CD Setup
The project includes a GitHub Actions workflow at.github/workflows/playwright.yml:1 that automatically runs tests on every push and pull request.
View GitHub Actions Workflow
View GitHub Actions Workflow
.github/workflows/playwright.yml
Key CI Features:
- Runs on Ubuntu latest
- Python 3.11
- Installs dependencies and browsers automatically
- Generates HTML and JUnit XML reports
- Uploads test results as artifacts (retained for 7 days)
- Triggered on push, PR, or manual dispatch
Playwright Configuration
- Browser Selection
- Headed vs Headless
- Device Emulation
- Debugging
Control which browser to use:
Troubleshooting
ModuleNotFoundError: No module named 'playwright'
ModuleNotFoundError: No module named 'playwright'
Solution: Ensure you’ve installed dependencies and activated your virtual environment:
Executable doesn't exist at path
Executable doesn't exist at path
Solution: Install Playwright browsers:
Tests timing out or running slowly
Tests timing out or running slowly
Solution: Check your internet connection and consider increasing timeouts:
RuntimeError: Missing USERNAME/PASSWORD in environment
RuntimeError: Missing USERNAME/PASSWORD in environment
Solution: Create a
.env file in the project root:Next Steps
Quickstart
Run your first test in minutes
Writing Tests
Learn how to write effective test cases
Page Object Model
Organize tests with the POM pattern
Advanced Features
Explore fixtures, parametrization, and more
You’re all set! Start writing tests and building your automation skills.