Answer
Playwright Inspector
The Playwright Inspector is a step-through GUI debugger for Playwright tests.
Launch Inspector
Bash
# Debug all tests
npx playwright test --debug
# Debug a specific file
npx playwright test login.spec.ts --debug
# Debug a specific test
npx playwright test -g "login with valid credentials" --debug
Add a Pause in Your Test
TypeScript
test('debug this', async ({ page }) => {
await page.goto('/login');
// Execution pauses here — Inspector opens
await page.pause();
await page.getByLabel('Email').fill('user@test.com');
// ... continue debugging
});
Inspector Features
- ✓Step Over — execute next line
- ✓Continue — run until next pause/breakpoint
- ✓Pick Locator — click any element to generate its locator
- ✓Action Log — list of all actions and their timing
- ✓Live CSS Selector input — test locators in real time
- ✓Source code panel — current line highlighted
✦
Playwright UI Mode
UI Mode is a fully interactive test runner with a graphical interface — great for developing and debugging tests.
Launch UI Mode
Bash
npx playwright test --ui
UI Mode Features
- ✓Test tree sidebar — all tests organized by file and describe block
- ✓Run/filter controls — run all, run selected, filter by status
- ✓Live trace viewer — DOM snapshots at each step as you watch the test
- ✓Watch mode — re-runs tests when files change
- ✓Time travel — click any action to see the DOM at that exact moment
- ✓Network tab — all HTTP requests per test
- ✓Console tab — browser console output
Use UI Mode for Development
Bash
# Run in watch mode — tests re-run on file save
npx playwright test --ui
# From UI Mode you can:
# - Filter tests by tag: @smoke, @regression
# - Re-run failed tests only
# - Pin tests to always show at top
# - View video, screenshots, and traces inline
When to Use Each
| Tool | When to Use |
|---|---|
| Inspector | Step-through debugging a specific failing test |
| UI Mode | Developing new tests, exploring what's happening |
| Trace Viewer | Analyzing CI failures post-run |
| --headed | Quick visual check of test execution |
