How do you capture full-page screenshots at multiple viewport sizes?

Capture full-page screenshots by setting each viewport size before navigation, waiting for the page’s stable state and asking the browser automation tool to include the full scrollable document. Use distinct filenames that include width, height, browser and page state. A full-page image uses viewport width but extends beyond viewport height.
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
for (const width of [360, 768, 1280]) {
await page.setViewportSize({ width, height: 900 });
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' });
await page.screenshot({ path: `home-${width}.png`, fullPage: true });
}
await browser.close();
Wait for the condition the page actually needs. Network idle can be misleading on sites with analytics or live connections, so wait for a known element, font readiness and required images. Disable animations and caret blinking. Seed repeatable data and close cookie banners through a test setup instead of cropping them away.
Lazy-loaded content may never appear unless the test scrolls through the page before capture. Some sticky elements repeat or change during a stitched screenshot. Decide whether the artifact should represent the whole document or a user’s visible viewport, then add separate viewport captures for sticky headers, dialogs and keyboard-sensitive controls.
Run screenshots in a stable browser and operating-system environment. Font fallback, device scale factor and browser updates can change image output. Use CSS-pixel scale for ordinary layout comparison and device scale only when the task needs high-density rendering evidence.
Organize files by route and state, and compare them through a reviewed visual-regression workflow instead of inspecting hundreds manually. A screenshot cannot prove that links work or focus is visible, so include interaction tests at the same widths. Keep physical-device screenshots for defects that emulation cannot reproduce.