plugins/aai-stack-playwright/skills/playwright-debugging/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/the-answerai/alphaagent-team/blob/main/plugins/aai-stack-playwright/skills/playwright-debugging/SKILL.md -a claude-code --skill playwright-debuggingInstallation paths:
.claude/skills/playwright-debugging/# Playwright Debugging Skill
Techniques for debugging Playwright tests.
## Debug Mode
### Using --debug
```bash
# Run with inspector
npx playwright test --debug
# Debug specific test
npx playwright test tests/login.spec.ts --debug
# Debug specific line
npx playwright test tests/login.spec.ts:15 --debug
```
### PWDEBUG Environment Variable
```bash
# Enable Playwright Inspector
PWDEBUG=1 npx playwright test
# Console debug mode
PWDEBUG=console npx playwright test
```
### In-Code Debugging
```typescript
test('debug this test', async ({ page }) => {
await page.goto('/')
// Pause and open inspector
await page.pause()
await page.click('button')
})
```
## Playwright Inspector
### Inspector Features
```typescript
// Inspector opens automatically with --debug
// Features:
// - Step through actions
// - View selectors
// - Record new steps
// - Explore elements
// - View console logs
```
### Recording Actions
```bash
# Start codegen to record tests
npx playwright codegen https://example.com
# With specific viewport
npx playwright codegen --viewport-size=800,600 https://example.com
# Save to file
npx playwright codegen -o tests/recorded.spec.ts https://example.com
```
## Trace Viewer
### Enabling Traces
```typescript
// playwright.config.ts
export default defineConfig({
use: {
trace: 'on-first-retry', // Only on retry
// trace: 'on', // Always
// trace: 'retain-on-failure', // Keep on failure
},
})
// Or per test
test.use({ trace: 'on' })
// Or in beforeAll
test.beforeAll(async ({ browser }, testInfo) => {
testInfo.config.use.trace = 'on'
})
```
### Viewing Traces
```bash
# Open trace viewer
npx playwright show-trace trace.zip
# View from test results
npx playwright show-report
# Click on test, then "Traces" tab
```
### Trace Contents
```
Trace includes:
- Screenshots at each action
- DOM snapshots
- Network requests
- Console logs
- Test source
- Action timeline
```
## Screenshots
### Capture Screenshots
``