2

I'm trying to capture a full page screenshot for visual regression with Playwright. Per their docs, it can be done like so:

import { test, expect } from '@playwright/test';

test('example test', async ({ page }) => {
  await page.goto('https://playwright.dev');
  await expect(page).toHaveScreenshot();
});

This works great, the only problem is it will only take a screenshot of the viewport. Is it possible to capture a full page screenshot for visual comparison?

Kode_12
  • 4,506
  • 11
  • 47
  • 97

1 Answers1

2

The answer is to include 'fullPage' optional property as part of the toHaveScreenshot() method:

import { test, expect } from '@playwright/test';

test('example test', async ({ page }) => {
  await page.goto('https://playwright.dev');
  await expect(page).toHaveScreenshot({ fullPage: true });
});
Kode_12
  • 4,506
  • 11
  • 47
  • 97