Before getting started, ensure you have the following installed:
- Node.js (latest LTS version recommended)
- Visual Studio Code
Once installed:
-
Open the specified project folder in VS Code or
-
Clone the repository using:
git clone <repository-url>
Initialize Playwright in your project:
npm init playwright
Follow the prompts to set up your desired configuration (browsers, example tests, etc.).
Runs all tests based on the testDir configured in playwright.config.js.
npx playwright test
Overrides headlines: true in config to show the browser UI.
npx playwright test --headed
npx playwright test /
npx playwright test tests/UIBasics.spec.js
npx playwright test / --debug
npx playwright test tests/UIBasics.spec.js --debug
Launch the Playwright inspector to generate tests via code recording:
npx playwright codegen
npx playwright codegen https://google.com
Open trace files in your browser for debugging:
Website: https://trace.playwright.dev/
Or use the CLI command:
npx playwright show-trace <path-to-trace.zip>
npm install
npx playwright install