Runs the end-to-end tests:
npx playwright test
Run tests in headed browsers:
npx playwright test --headed
Starts the interactive UI mode:
npx playwright test --ui
Runs the tests only on Desktop Chrome:
npx playwright test --project=chromium
Runs the tests in a specific file.:
npx playwright test example
Runs the tests in debug mode:
npx playwright test --debug
Auto-generate tests with Codegen:
npx playwright codegen
Runs the tests with specific workers number
npx playwright test exercise-learnings --workers 4
If you set workers to 1. It will become serial instead of the paralel running, one after another.
npx playwright test exercise-learnings --workers 1
npx playwright test
Playwright Test for VSCode
Playwright Test Snippets
Playwright Runner
Playwright Trace Viewer for VSCode
- Debug in Console
DEBUG=pw:api basic_test_command
DEBUG=pw:api npx playwright test home.spec.ts -g "Open\s+About\s+Page\s+and\s+verify\s+title$"
- Debug with Trace Viewer
- Open the playwright.cnfig.ts file
- Use the "trace: 'on'," command instead of "trace: 'on-first-retry',"
- Run a test with the "Execute Playwright Tests" extension trace on what will work for each particular test Also, it will open the report automatically and you will find a Trace section below.
- Debug with Inspector
It will open a playwright inspector and you can debug it by clicking the next step button. So it gives an opportunity to watch lines step by step
PWDEBUG=1 basic_test_command
PWDEBUG=1 npx playwright test assertions.spec.ts -g "Avoid\s+running\s+further\s+if\s+there\s+were\s+soft\s+assertion\s+failures$"
- Debug with Record
Put
await page.pause();
to your code and debug with inspector
https://fakerjs.dev/guide/ https://fakerjs.dev/api/
npm install @faker-js/faker --save-dev
For Example: visit the "secondChallenge.spec.ts" test file
- List Reporter
npx playwright test exercise-learnings/secondChallenge.spec.ts --reporter=list
- Line Reporter
npx playwright test exercise-learnings/secondChallenge.spec.ts --reporter=line
- html Reporter
npx playwright test exercise-learnings/secondChallenge.spec.ts --reporter=html
- Dot Reporter
npx playwright test exercise-learnings/secondChallenge.spec.ts --reporter=dot
- json Reporter
npx playwright test exercise-learnings/secondChallenge.spec.ts --reporter=json
- Allure Reporter
npm i -D @playwright/test allure-playwright
npm i -D allure-commandline
npx allure generate allure-results --clean && npx allure open
npm install eslint --save-dev
npm i eslint-plugin-playwright --save-dev
npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev
Then install VS Code ESLint extension
Create .eslintrc ( /../../PlaywrightAutomation/.eslintrc ) file
npx eslint exercise-learnings/
will show all warnings and errors in my code
You can use https://trace.playwright.dev/ for opening trace.zip as a readable report