$ npm init playwright@latest new-project
npm WARN exec The following package was not found and will be installed: create-playwright@latest
Getting started with writing end-to-end tests with Playwright:
Initializing project in 'new-project'
? Do you want to use TypeScript or JavaScript? · JavaScript
? Do you want to use TypeScript or JavaScript? · JavaScript
? Where to put your end-to-end tests? » tests
? Where to put your end-to-end tests? · tests
? Add a GitHub Actions workflow? (Y/n) » true
? Add a GitHub Actions workflow? (Y/n) · true
installer ça
https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright
npm init playwright@latest -- --quiet --browser=chromium --browser=firefox --browser=webkit --install-deps
mettre ça dans le fichier ./tests/example.spec.ts
const { test, expect } = require('@playwright/test');
test('basic test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const title = page.locator('.navbar__inner .navbar__title');
await expect(title).toHaveText('Playwright');
// await page.pause();
});
lancer les tests
npx playwright test
npx playwright test --project=webkit --headed