Download and install Node : https://nodejs.org/en/download
Create folder to start project and install Playwright in it
git init
npm init playwright@latest
playwright.config.ts
Test configuration | Playwright
timeout: 30_000, // 30 seconds time out for testcases - if more than 30 seconds, test will fail
globalTimeout: 10 * 60 * 1000, // 10 minutes timeout for the entire test suite run
trace: 'on', // Collect trace for failed tests
actionTimeout: 0, // Disable action timeout
ignoreHTTPSErrors: true, // Ignore HTTPS errors
video: 'retain-on-failure', // Record videos
screenshot:'only-on-failure', // Take screenshots only on failure
headless: true, // Run tests in headless mode
testIdAttribute: 'data-test', // Use data-test-id attribute for selectors
npm install
{
"name": "playwright-learning",
"version": "1.0.0",
"main": "index.js",
"scripts": {
// here we can create alias for our command
"test": "npx playwright test",
"test-chromium": "npx playwright test --project chromium",
"test-firefox": "npx playwright test --project firefox",
"test-safari": "npx playwright test --project webkit",
"test-report": "npx playwright test && npx playwright show-report"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.5"
}
}