August 28th 2024
New
Playwright has a built-in ability to perform a Visual Comparison.
test('example test', async ({ page }) => {
await page.goto('https://playwright.dev');
await expect(page).toHaveScreenshot({ maxDiffPixels: 100 });}
);
Playwright will fail a test if the current snapshot differs from a reference image.
Weâve released a first-class support for displaying the visual comparison screenshots, including browsing the diff, actual, expected, side by side and slider widget.
The support is automatic and doesnât require any action other than just using toHaveScreenshot
directive.