End-to-end UI tests using Playwright with Python and Pytest.
- Python 3.10+
- Install dependencies:
pip install -r requirement.txt - Install browsers:
playwright install
- Run all tests:
pytest -v - Headed mode:
pytest -v --headed - Specify a test:
pytest tests/test_checkout_flow.py::test_guest_checkout
Follow these steps to push this existing local project to a new GitHub repository.
Prerequisites:
- A GitHub account
- Git installed locally (
git --versionshould work)
Steps:
- Initialize the local repository (if not already a git repo)
- In the project root, run:
git init
- In the project root, run:
- Set your name and email (one-time global setup)
git config --global user.name "Your Name"git config --global user.email "you@example.com"
- Ensure the .gitignore file exists (this repo provides one). Stage files:
git add .
- Make the first commit:
git commit -m "Initial commit: Playwright Python E2E project"
- Create a new repository on GitHub
- Go to https://github.com/new
- Choose the repository name (e.g.,
e2e-playwright-python), set visibility, and click "Create repository"
- Connect your local repo to GitHub
- Copy the commands GitHub shows after creation. Typically one of:
- Using HTTPS:
git remote add origin https://github.com/<your-username>/<repo-name>.git
- Or using SSH (recommended if you use SSH keys):
git remote add origin git@github.com:<your-username>/<repo-name>.git
- Using HTTPS:
- Copy the commands GitHub shows after creation. Typically one of:
- Push your code
- If your local default branch is
main:git branch -M maingit push -u origin main
- If you prefer
master, adapt the branch name accordingly.
- If your local default branch is
Authentication tips:
- HTTPS: the first push will prompt for credentials. Use your GitHub username and a Personal Access Token (classic) as the password (create at https://github.com/settings/tokens, grant repo scope).
- SSH: ensure you have an SSH key added to GitHub (https://github.com/settings/keys). Test with
ssh -T git@github.com.
Updating later:
- After making changes:
git add -A && git commit -m "Describe your change" && git push
You can add GitHub Actions for automatic test runs. Example workflow (save as .github/workflows/ci.yml):
name: CI
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: pip install -r requirement.txt
- run: npx playwright install --with-deps
- run: pytest -v