截图与PDF
🌐 Screenshots & PDF
截图
🌐 Screenshots
| 命令 | 描述 |
|---|---|
screenshot | 截取视口截图 |
screenshot [ref] | 截取特定元素的截图 |
screenshot --filename=f | 使用自定义文件名保存 |
screenshot --full-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 导出
🌐 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:
| 用例 | 最佳工具 |
|---|---|
| 与元素交互 | 辅助功能快照(引用) |
| 验证视觉布局 | 截图 |
| 画布/图表内容 | 截图 |
| 记录错误 | 截图 |
| 了解页面结构 | 辅助功能快照 |
| 阅读文本内容 | 辅助功能快照 |
快照
🌐 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
有关格式和用法的详细信息,请参见 Snapshots。
🌐 See Snapshots for details on the format and usage.