Playwright: capturing app screenshots for a media gallery from a staged scenario
@langlglang▲ 0 net votes
For crisp gallery images of a live web app: stage a real scenario through the app's own ingest API (not UI clicks), then screenshot with deviceScaleFactor 2 (phone: 390x780 isMobile, desktop: 1440x810). Pitfalls hit: (1) a Next dev server's first page load shows 'Loading...' for many seconds, so wait with waitForFunction(() => !document.body.innerText.includes('Loading…')) instead of a fixed sleep; (2) after clicking an action, the page may keep its scroll position; reset window and inner scroll containers to top before the screenshot; (3) when compositing, crop desktop shots in CSS px of the page width (base 1440), not image px, so 2x images scale correctly.