playwright-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlaywright CLI
Playwright CLI
Terminal-based browser automation using . This skill covers the CLI surface: running tests, generating test code via , taking screenshots/PDFs, and CI sharding flags.
npx playwrightcodegen基于终端的浏览器自动化工具,使用。本技能涵盖CLI层面的操作:运行测试、通过生成测试代码、截取屏幕截图/生成PDF,以及CI分片参数。
npx playwrightcodegenScope boundary
范围边界
| I want to... | Use |
|---|---|
| Run E2E tests | |
| Record a browser session → test code | |
| One-off screenshot / PDF from a URL | |
| Write / review / tune a Playwright test suite | |
| Agent-driven real-time browser control (navigate → click → read → assert) | |
| Interactive data scraping / SPA exploration | |
For data scraping / SPA flows where you need to programmatically navigate, click "Load More", extract DOM, and save JSON: write a and run . See skill for the test-authoring patterns.
tests/*.spec.tsnpx playwright testplaywright-test| 我想要... | 使用方案 |
|---|---|
| 运行E2E测试 | |
| 录制浏览器会话→生成测试代码 | |
| 从URL一次性截取屏幕截图/生成PDF | |
| 编写/审阅/调整Playwright测试套件 | |
| 由Agent驱动的实时浏览器控制(导航→点击→读取→断言) | |
| 交互式数据爬取/SPA探索 | |
对于需要程序化导航、点击“加载更多”、提取DOM并保存JSON的数据爬取/SPA流程:编写文件并运行。有关测试编写模式,请查看技能。
tests/*.spec.tsnpx playwright testplaywright-testQuick Reference
快速参考
bash
undefinedbash
undefinedInteractive codegen (generates test code from browser actions)
Interactive codegen (generates test code from browser actions)
npx playwright codegen https://example.com
npx playwright codegen https://example.com
Run all tests
Run all tests
npx playwright test
npx playwright test
Run specific file
Run specific file
npx playwright test tests/login.spec.ts
npx playwright test tests/login.spec.ts
Run specific test by title
Run specific test by title
npx playwright test -g "should login"
npx playwright test -g "should login"
Debug mode (opens Playwright Inspector)
Debug mode (opens Playwright Inspector)
npx playwright test --debug
npx playwright test --debug
UI mode (visual test runner with time-travel)
UI mode (visual test runner with time-travel)
npx playwright test --ui
npx playwright test --ui
Headed mode (see the browser)
Headed mode (see the browser)
npx playwright test --headed
npx playwright test --headed
Specific browser
Specific browser
npx playwright test --project=chromium
npx playwright test --project=chromium
Generate trace
Generate trace
npx playwright test --trace on
npx playwright test --trace on
View report
View report
npx playwright show-report
npx playwright show-report
Install browsers
Install browsers
npx playwright install
npx playwright install chromium --with-deps # CI-optimized
undefinednpx playwright install
npx playwright install chromium --with-deps # CI-optimized
undefinedSharding for CI
CI分片
bash
npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=3/3bash
npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=3/3Screenshot / PDF
屏幕截图/PDF
bash
undefinedbash
undefinedScreenshot from CLI
Screenshot from CLI
npx playwright screenshot --browser=chromium https://example.com screenshot.png
npx playwright screenshot --browser=chromium https://example.com screenshot.png
PDF (Chromium only)
PDF (Chromium only)
npx playwright pdf https://example.com page.pdf
undefinednpx playwright pdf https://example.com page.pdf
undefined