← Back to library
Playwrightvisualadvancedv1.20+
Full-page screenshot comparison
Capture a full-page screenshot and compare it against a stored baseline.
1test('home page matches visual baseline', async ({ page }) => {
2 await page.goto('/home');
3
4 // Wait for images, fonts, and animations to settle
5 await page.waitForLoadState('networkidle');
6
7 // First run creates the baseline PNG; subsequent runs diff against it
8 await expect(page).toHaveScreenshot('home-page.png', {
9 fullPage: true,
10 maxDiffPixelRatio: 0.02, // tolerate 2% pixel difference (anti-aliasing)
11 });
12});#screenshot#visual regression#baseline#toHaveScreenshot