[Feature] 'toHaveScreenshot' should have ability to capture full page.
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 You can pass fullPage option, see here.
@KunalOjha You can pass
fullPageoption, see here.
Can ‘Element screenshot’ capture a screenshot with scrollbars like fullPage does?
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
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.
Have you tried: await expect(page).toHaveScreenshot({ fullPage: true });?
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.