A modern Playwright TypeScript test automation framework with Page Object Model, custom fixtures, multi-browser support, and comprehensive example tests.
- the-internet.herokuapp.com — primary test target
- demo.playwright.dev/todomvc — TodoMVC app tests
- httpbin.org — API testing examples
# Install dependencies
yarn install
# Install Playwright browsers
npx playwright install --with-deps# Run all tests (all browsers)
yarn test
# Run on a specific browser
yarn test:chromium
yarn test:firefox
yarn test:webkit
# Run in headed mode (see the browser)
yarn test:headed
# Run with Playwright UI mode
yarn test:ui
# Run with debugger
yarn test:debug
# Run only changed tests
yarn test:only-changed
# Re-run last failed tests
yarn test:last-failed
# Run tests matching a grep pattern
npx playwright test --grep "@smoke"
# Run a single test file
npx playwright test tests/smoke.spec.ts# Generate and open Allure report
yarn reportHTML reports are generated in html-report/ after each test run.
├── pages/ # Page Object Model classes
│ ├── BasePage.ts # Base class with common locator helpers
│ ├── HomePage.ts # the-internet homepage
│ ├── LoginPage.ts # Login page
│ ├── ToDoPage.ts # TodoMVC page
│ └── ... # Other page objects
├── tests/
│ ├── fixtures.ts # Custom test fixtures (auto-initialized page objects)
│ ├── auth.setup.ts # Global auth setup (saves storage state)
│ ├── smoke.spec.ts # Smoke tests (@smoke)
│ ├── demo-todo-app.spec.ts # TodoMVC tests (@regression)
│ ├── accessibility.spec.ts # Accessibility testing examples
│ ├── api-testing.spec.ts # API testing examples (httpbin.org)
│ ├── network.spec.ts # Network interception & mocking
│ ├── visual-comparison.spec.ts # Screenshot/visual testing
│ ├── clock.spec.ts # Clock API examples
│ ├── advanced-interactions.spec.ts # Hover, keyboard, downloads, dialogs
│ ├── locators.spec.ts # Modern locator patterns
│ └── multi-browser.spec.ts # Cross-browser annotations & tags
├── playwright.config.ts # Playwright configuration
├── .env # Environment variables
└── .github/workflows/ # CI pipeline
- Create a new
.spec.tsfile intests/ - Import from
./fixturesto use custom fixtures (homePage,loginPage,todoPage) or from@playwright/testfor standalone tests - Use tags like
@smokeor@regressionin test/describe names for filtering
- Create a new class in
pages/extendingBasePage - Use
BasePagehelpers:testID(),button(),label(),text(),placeHolder(),altText(),title(),role() - Optionally add the page object to
tests/fixtures.tsfor auto-initialization
- Prettier: single quotes, no trailing commas, 2-space indent, 80 char width
- ESLint with TypeScript and Playwright plugins
- Husky pre-commit hook runs formatting and linting
yarn format
yarn lintGitHub Actions runs on push/PR to main. Uses Playwright Docker container. HTML and blob reports are uploaded as artifacts.
New to Playwright or test automation? Follow this suggested learning order:
tests/getting-started.spec.ts— 10 simple, heavily-commented tests covering the basics:- Navigating to pages
- Finding elements (roles, text, CSS)
- Clicking and form filling
- Checkboxes and dropdowns
- Waiting for dynamic content
- Screenshots and test steps
pages/BasePage.ts— Read the class documentation to understand locator helperstests/fixtures.ts— Learn how fixtures auto-initialize page objectstests/smoke.spec.ts— See how tests use fixtures and page objects together
| File | What You'll Learn |
|---|---|
locators.spec.ts |
and(), or(), filter(), chaining, frames |
multi-browser.spec.ts |
Browser-specific tests, tags, serial mode |
advanced-interactions.spec.ts |
Hover, keyboard, downloads, dialogs |
network.spec.ts |
Request interception, mocking responses |
api-testing.spec.ts |
REST API testing with request fixture |
clock.spec.ts |
Time manipulation for testing timers |
visual-comparison.spec.ts |
Screenshot comparison testing |
accessibility.spec.ts |
ARIA assertions and accessibility |
- Pick a page on the-internet.herokuapp.com not yet covered
- Create a page object in
pages/extendingBasePage - Write tests in
tests/using your page object - Add your page object to
tests/fixtures.tsif you'll reuse it
# Run a single test file with UI to see what's happening
npx playwright test tests/getting-started.spec.ts --ui
# Run tests in debug mode (pauses at each step)
npx playwright test tests/getting-started.spec.ts --debug
# Generate tests by recording your actions
npx playwright codegen https://the-internet.herokuapp.com