← All projects
Playwright UI Suite in Python
A pytest + Playwright end-to-end suite for the Sauce Labs demo store, covering login through checkout with the Page Object Model and Faker-generated test data.
Overview
The same Sauce Labs demo store as my TypeScript suite, this time with Python’s testing tools: Playwright for Python through pytest-playwright, organized around the Page Object Model.
Test coverage
- Login: successful login, invalid credentials, and a locked-out user.
- Logout: logging out, and checking that a logged-out session can’t reach the inventory page.
- Products: the product grid and detail pages, adding and removing items from both, and sorting by name and price.
- Cart and checkout: viewing and removing items, completing checkout with one or more products using randomized Faker customer data, checking the required-field errors, and cancelling checkout.
Engineering details
- Shared session: pytest fixtures in
conftest.pylog in once per session using Playwright’s storage state, and every test that needs a signed-in user reuses it. This avoids a fresh UI login for each test. - Settings in
pytest.ini: the base URL, browser choice and failure artifacts (screenshots, video, traces) are all set there, so a plainpytestrun needs no flags. Each run also produces an HTML report. - Code quality: Ruff handles linting and formatting, enforced locally with
pre-commithooks and in CI. - GitLab CI: every push runs lint, the full suite in the official Playwright Python image, SAST and secret detection. Test reports are kept as artifacts.