Linux command
playwright 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Install browsers
npx playwright install
Run tests
npx playwright test
Run specific test
npx playwright test [test.spec.ts]
Run with UI mode
npx playwright test --ui
Generate code
npx playwright codegen [url]
说明
Playwright is a framework for browser automation and testing. It supports Chromium, Firefox, and WebKit with a unified API for cross-browser testing.
参数
- install _browser_
- Install browsers (chromium, firefox, webkit) and dependencies.
- install-deps
- Install OS-level dependencies required by browsers (Linux).
- test _files_
- Run Playwright tests.
- codegen _url_
- Record user actions and generate test code.
- show-report _dir_
- Open the HTML report in a browser.
- open _url_
- Open a page in Playwright inspector.
- --ui
- Launch interactive UI mode for running and debugging tests.
- --debug
- Run tests in debug mode with Playwright Inspector.
- --headed
- Run browsers in headed mode (visible window).
- --project _NAME_
- Run only the given project (browser) from the config.
- --workers _N_
- Number of parallel test worker processes.
- --reporter _NAME_
- Reporter to use (list, dot, line, html, json, junit).
- --grep _PATTERN_
- Only run tests matching the regex pattern.
- --retries _N_
- Number of times to retry failing tests.
FAQ
What is the playwright command used for?
Playwright is a framework for browser automation and testing. It supports Chromium, Firefox, and WebKit with a unified API for cross-browser testing.
How do I run a basic playwright example?
Run `npx playwright install` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does install _browser_ do in playwright?
Install browsers (chromium, firefox, webkit) and dependencies.