Automate your web testing using Playwright and Python. This project provides end-to-end testing capabilities with pytest and Playwright for modern web applications.
- ✅ Fast & Reliable Browser Automation with Playwright
- ✅ Headless Mode for running tests in the background
- ✅ Cross-Browser Support (Chromium, Firefox, WebKit)
- ✅ Easy Configuration using
pytest
- ✅ Parallel Test Execution
- ✅ Allure Reports for Test Insights
Make sure you have the following installed:
- Python 3.7+
- Node.js (for Playwright CLI)
poetry
package manager
Clone the repository and install dependencies:
# Clone the repository
git clone https://github.com/hbkandhi12/playwright-python-tests.git
cd playwright-python-tests
# Install dependencies using Poetry
poetry install
# Install Playwright browsers
poetry run playwright install
Run Playwright tests using pytest
:
poetry run pytest --headed # Runs tests with a visible browser
poetry run pytest --headless # Runs tests in headless mode (faster)
Run tests in parallel:
poetry run pytest -n auto # Runs tests in parallel using multiple CPU cores
Generate an Allure Report:
poetry run pytest --alluredir=allure-results
poetry run allure generate allure-results -o allure-report --clean
playwright-python-tests/
│── tests/
│ ├── test_login.py # Login page test cases
│ ├── test_checkout.py # Checkout workflow tests
│
│── pages/
│ ├── login_page.py # Page Object Model for login page
│ ├── inventory_page.py # Page Object Model for inventory
│
│── conftest.py # Pytest fixtures
│── pyproject.toml # Poetry configuration file
│── README.md # Project documentation
To automatically generate and deploy Allure Reports on GitHub Pages, add the following GitHub Actions workflow:
Create .github/workflows/allure-report.yml
and add:
name: Playwright Tests & Allure Report
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Install Playwright browsers
run: poetry run playwright install
- name: Run tests and generate Allure results
run: poetry run pytest --alluredir=allure-results
- name: Generate Allure Report
run: |
poetry run allure generate allure-results -o allure-report --clean
- name: Deploy Allure Report to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./allure-report
Make sure GitHub Pages is enabled in your repo settings under Settings > Pages and set it to deploy from gh-pages
branch.
Want to improve this project? Contributions are welcome! 🚀
- Fork the repository
- Create a new branch (
feature-branch
) - Commit your changes (
git commit -m 'Add new feature'
) - Push to the branch (
git push origin feature-branch
) - Open a Pull Request
Have a question or feature request? Create an issue or start a GitHub discussion!
- 📌 Issues: Submit here
- 💬 Discussions: Join here
This project is licensed under the MIT License.