playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] 'toHaveScreenshot' should have ability to capture full page.

Open KunalOjha opened this issue 2 years ago • 1 comments

I have created a feature request for the ability of PlayWright's Visual Comparison flow to allow users the ability to capture full page screenshots for comparisons. I don't believe there is a way to configure this using the toHaveScreenShot method as outlined in the docs

Currently this is the way Playwright recommends to perform snapshot comparisons:

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

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

KunalOjha avatar May 23 '23 20:05 KunalOjha

@KunalOjha You can pass fullPage option, see here.

dgozman avatar May 24 '23 02:05 dgozman

@KunalOjha You can pass fullPage option, see here.

Can ‘Element screenshot’ capture a screenshot with scrollbars like fullPage does?

627668410 avatar May 31 '23 11:05 627668410

Can ‘Element screenshot’ capture a screenshot with scrollbars like fullPage does?

Do you mean "full contents of the element, including scrolled out content"? If so, that's not possible. Element screenshot captures the visible contents of a single element, including scrollbars if the element has them.

dgozman avatar May 31 '23 14:05 dgozman

@dgozman

Just as you mentioned, my page has a fixed header, and I would like the content section below it to be fully captureable in screenshots.

627668410 avatar Jun 01 '23 02:06 627668410

Have you tried: await expect(page).toHaveScreenshot({ fullPage: true });?

mxschmitt avatar Jun 02 '23 20:06 mxschmitt

The original request by @KunalOjha is solved by fullPage option - so closing this.

@627668410 please file a separate issue to not fork the discussion here.

aslushnikov avatar Jun 07 '23 18:06 aslushnikov