A lightweight Python project demonstrating web UI automation with Playwright, data-driven testing using Excel, and pytest fixtures/page-object patterns. This repository is ideal for beginners learning Playwright with Python, or anyone exploring structured test automation frameworks.
play_with_playwright/
│
├── data/
│ └── test_data.xlsx # Excel file containing test input data
│
├── pages/
│ ├── base_page.py # Shared base class for all page objects
│ └── form_page.py # Page object for interacting with a sample form
│
├── tests/
│ └── test_form_excel.py # Test reading Excel data + filling form via Playwright
│
├── fixtures/
│ └── browser_fixture.py # Pytest fixture configuring Playwright browser context
│
├── utils/
│ └── excel_reader.py # Utility module for reading Excel files
│
├── pytest.ini # Pytest configuration
└── requirements.txt # Python dependencies
- ✔️ Playwright for Web UI automation
- ✔️ Page Object Model (POM) for clean and maintainable test code
- ✔️ Excel-driven test data (via
openpyxlor similar library) - ✔️ Reusable pytest fixtures for browser lifecycle
- ✔️ Example form automation test reading multiple rows from Excel
-
Clone the repository:
git clone https://github.com/yourname/play_with_playwright.git cd play_with_playwright -
Install dependencies:
pip install -r requirements.txt
-
Install Playwright browsers:
playwright install
Run all tests:
pytestRun with headed browser mode:
pytest --headedRun a specific test:
pytest tests/test_form_excel.pyutils/excel_reader.py loads test rows from data/test_data.xlsx.
Each row is passed as input into the test.
base_page.pyprovides common functions such as navigation, element handling, etc.form_page.pyimplements actions for a specific web form.
browser_fixture.py creates a browser/page instance so tests remain clean and modular.
test_form_excel.py iterates through Excel rows and fills out the form for each dataset.
See requirements.txt, typically including:
playwrightpytestopenpyxl(if reading Excel)- other utility libraries as needed
Pull requests are welcome! If you’d like to add features, contribute enhancements, or improve documentation, feel free to fork and submit a PR.
MIT.