Back to feed
Dev.to
Dev.to
6/24/2026
How to Take Screenshots in Playwright (Full Page, Elements, CI)

How to Take Screenshots in Playwright (Full Page, Elements, CI)

Short summary

Playwright's page.screenshot() method captures full pages for testing, but sticky headers repeat in stitched sections and lazy-loaded content may be missed entirely. Fixes include hiding fixed elements with CSS injection, manually scrolling before capture, and using fullPage: true with proper waitUntil options. For production screenshots, dedicated APIs are faster to operate—Chromium deployment brings cold-start overhead, concurrency management, and SSRF security concerns that are better offloaded.

  • Use fullPage: true for full captures, but watch for sticky/fixed headers repeating and lazy content clipping
  • Manually scroll pages before fullPage capture to trigger lazy-loaded renders
  • In CI, use `npx playwright install --with-deps` (not just install) to pull OS libraries Chromium requires

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more