|
1 month ago | |
---|---|---|
.vscode | 1 month ago | |
files | 1 month ago | |
tests-examples | 1 month ago | |
.env | 1 month ago | |
.gitignore | 1 month ago | |
README.md | 1 month ago | |
env.config.js | 1 month ago | |
package.json | 1 month ago | |
playwright.config.js | 1 month ago |
npx playwright test # 运行所有测试(默认 Chromium) npx playwright test tests/login.spec.js # 运行指定测试文件 npx playwright test --grep "login test" # 运行匹配名称的测试 npx playwright test --grep @smoke # 运行带标签的测试(如 @smoke) npx playwright test --grep-invert "@slow" # 排除特定标签的测试 npx playwright test --ui # 启动 UI 模式(交互式调试) npx playwright test --debug # 调试模式(禁用无头模式)
npx playwright test --browser=firefox # 指定浏览器(chromium|firefox|webkit) npx playwright test --browser=all # 在所有浏览器上运行 npx playwright test --project=Mobile # 运行指定项目(需配置) npx playwright test --config=custom.config.js # 指定自定义配置 npx playwright test --ci # CI 模式(自动检测环境) npx playwright test --headed # 强制显示浏览器(禁用无头模式)
npx playwright show-report # 生成并打开 HTML 报告 npx playwright test --reporter=junit # 生成 JUnit 报告(CI 友好) npx playwright test --reporter=json # 生成 JSON 报告 npx playwright test --verbose # 显示详细日志 npx playwright test --quiet # 静默模式(减少输出)
npx playwright test --update-snapshots # 更新测试快照 npx playwright test --update-snapshots=fail # 仅更新失败的快照 npx playwright test --retries=3 # 失败时自动重试 npx playwright test --repeat-each=2 # 重复运行测试(非失败重试) npx playwright test --workers=2 # 设置并发 worker 数量 npx playwright test --workers=1 # 禁用并发(串行运行)
npx playwright install # 安装所有支持的浏览器 npx playwright install chromium # 仅安装 Chromium npx playwright install --with-deps # 安装浏览器及系统依赖 npx playwright codegen example.com # 启动代码生成器(录制测试) npx playwright codegen --browser=firefox # 在指定浏览器录制
npx playwright test --timeout=60000 # 设置全局超时(毫秒) npx playwright test --slowmo=1000 # 慢速模式(延迟操作) npx playwright test tests/login.spec.js:10 # 运行文件中特定测试块 npx playwright --help # 打印所有可用命令
npx playwright codegen # 启动 Codegen。 npx playwright codegen example.com # 指定录制目标网站