Screenshots & PDF
Screenshots
| Command | Description |
|---|---|
screenshot | Screenshot of the viewport |
screenshot [ref] | Screenshot of a specific element |
screenshot --filename=f | Save with custom filename |
screenshot --full-page | Full scrollable page |
$ playwright-cli screenshot
# Screenshot saved to .playwright-cli/screenshot-2026-03-15.png
$ playwright-cli screenshot e15
# Screenshot of element e15
$ playwright-cli screenshot --filename=login-page.png
$ playwright-cli screenshot --full-page --filename=full-page.png
PDF export
playwright-cli pdf # save with auto-generated name
playwright-cli pdf --filename=page.pdf # save with custom name
When to use screenshots
Screenshots complement accessibility snapshots:
| Use case | Best tool |
|---|---|
| Interacting with elements | Accessibility snapshot (refs) |
| Verifying visual layout | Screenshot |
| Canvas/chart content | Screenshot |
| Documenting a bug | Screenshot |
| Understanding page structure | Accessibility snapshot |
| Reading text content | Accessibility snapshot |
Snapshots
For accessibility tree output (not a visual capture):
playwright-cli snapshot # full page snapshot
playwright-cli snapshot --filename=f # custom filename
playwright-cli snapshot [ref] # element snapshot
playwright-cli snapshot --depth=N # limit depth
See Snapshots for details on the format and usage.