An example repo for demonstration fixing Playwright tests with AI.
-
Clone the repo
git clone https://github.com/vitalets/playwright-fix-with-ai.git cd playwright-fix-with-ai -
Install dependencies
npm install -
Install Playwright browsers
npx playwright install chromium -
Ensure test pass
npx playwright testOutput:
Running 1 test using 1 worker 1 passed (2.7s) -
Modify
test/sample.spec.tsto fail the test, e.g.:test('get started link', async ({ page }) => { await page.goto('https://playwright.dev'); - await page.getByRole('link', { name: 'Get started' }).click(); + await page.getByRole('button', { name: 'Get started' }).click(); await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); }); -
Run tests again
npx playwright test -
Open HTML report:
npx playwright show-report -
Click on
🤖 Fix with AIand copy prompt -
Paste prompt to ChatGPT
-
Apply ChatGPT suggested changes to fix the test