Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

Why Playwright Screenshots Show Lazy-Loaded Images as Blank on the First Run

Playwright can capture a page before deferred images are ready. Scroll target images into view, assert their loaded state, then take the screenshot.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Playwright screenshot can be taken before a lazy-loaded image has been requested, loaded, and painted. Waiting for the page’s load event—or asking for a full-page screenshot—does not guarantee that off-screen images are ready. Scroll the images you need into view, wait for an image-specific ready condition, and then capture.

Why lazy-loaded images are missing

Lazy loading postpones image requests until the browser or application decides they are needed, often when they approach the viewport. A screenshot can therefore arrive before the trigger or before the resulting image is ready to display. If the first run is blank but later runs work, a timing race is plausible; the symptom alone does not prove that caching is the cause.

As an Amazon Associate I earn from qualifying purchases.

Document lifecycle events and image readiness are different conditions. Playwright’s waitForLoadState('load') waits for the document’s load event, while DOMContentLoaded occurs earlier. Neither says that every image deferred until later scrolling has loaded. Playwright also notes that many actions already auto-wait and discourages using networkidle as a general test-readiness signal. See the Playwright Page API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the screenshot wait for the images it needs

  1. Identify the target images. Check whether the blank images are below the initial viewport, inside a scrolling container, or inserted or updated by client-side code. The right selector and loading trigger depend on the page.
  2. Inspect their state. Before and after scrolling, examine attributes and properties such as src, srcset, currentSrc, loading, complete, and naturalWidth. This helps distinguish an image that has not been requested from one whose request failed.
  3. Trigger the site’s loading behavior. Scroll each target image or its containing section into view. For a custom lazy loader, use the user-visible event the application expects; scrolling is not universal.
  4. Wait for a content-level condition. For a normal image, a positive naturalWidth is one useful success condition. If the application exposes a more specific loaded marker, prefer that. Avoid replacing the condition with a fixed sleep or generic networkidle wait.
  5. Capture after the condition passes. Use full-page capture if you need the full scrollable extent, but treat capture extent and image readiness as separate concerns.

Adaptable JavaScript example

This Playwright Test example scrolls images marked with loading="lazy" into view, waits for a nonzero natural width, and then takes a full-page screenshot:

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
import { test, expect } from '@playwright/test';

test('capture page after lazy images load', async ({ page }) => {
  await page.goto('https://example.com');

  const images = page.locator('img[loading="lazy"]');
  const count = await images.count();

  for (let i = 0; i < count; i++) {
    const image = images.nth(i);
    await image.scrollIntoViewIfNeeded();
    await expect(image).not.toHaveJSProperty('naturalWidth', 0);
  }

  await page.screenshot({ path: 'page.png', fullPage: true });
});

Replace the example URL and selector with the target page’s values. This is a pattern, not a guaranteed drop-in fix: a site may use custom attributes or JavaScript instead of loading="lazy", and its matching image list may change while the test runs. The Playwright issue example demonstrates scrolling and checking naturalWidth, while also noting that locator.all() returns immediately and can be unpredictable for a changing list: Playwright issue #31737.

Full-page screenshots and visual assertions

A full-page screenshot determines how much of the page is captured; it does not itself establish that every lazy image has loaded. For visual regression tests, Playwright’s toHaveScreenshot waits for two consecutive screenshots with the same result before comparing. Use that stabilization after triggering and checking the application state, not instead of doing so. The API is documented in Playwright PageAssertions.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Choose a readiness check that matches the page

Approach What it establishes Limitation
Wait for document load The document reached its load event. Does not establish that deferred, off-screen images are ready.
Wait for networkidle A period of network quiet. Playwright discourages it as a generic testing-readiness strategy; it does not assert the state of the target image.
Scroll and assert image or app state The test has triggered the relevant content and can check the image it needs. Requires a correct locator and a condition that reflects the page’s actual loading behavior.
Fixed timeout Only that a chosen amount of time elapsed. Can be unnecessarily slow or still too short; it does not prove successful loading.

Troubleshoot when the image is still blank

The image has no real URL

Inspect src, srcset, currentSrc, and any application-specific data attributes. Some sites assign the actual URL only after a trigger. If the URL is absent, adjust the trigger or selector rather than waiting longer for a request that has not started.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image request fails

Check browser console messages and failed network requests. A request failure is different from taking the screenshot too early; investigate the resource URL, response, or browser conditions before changing screenshot timing.

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

The image reports loaded but appears blank

Check whether CSS hides it or makes it transparent, whether an overlay covers it, whether it has been decoded and painted, and whether the screenshot targets the intended frame or element. A nonzero naturalWidth is evidence of an image resource, not proof that the visible result is correct.

Only the first run fails

Compare cold and warm runs while logging image state before and after scrolling. Later runs may benefit from cache or page state, but the symptom does not identify either as the cause. Keep the same viewport and target conditions so the comparison is useful.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The image list changes while the test loops

A list collected before scrolling may no longer match the current DOM if the page inserts or removes images. Re-evaluate the locator as needed or wait for the application’s list to stabilize. The GitHub issue cited above illustrates this risk; it does not mean every dynamic page will fail the same way.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The visual assertion is flaky

First ensure the app and intended images are ready. Then use toHaveScreenshot for its documented consecutive-screenshot stabilization, and account for other changing visual elements separately. Screenshot stabilization cannot trigger lazy loading or fix a failed image request.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot or PDF; cookie banners, newsletter popups, and chat widgets are removed before capture, and those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status. Its MCP server gives AI agents tools to take screenshots, inspect page information, and capture PDFs.

Example cURL request (replace the URL with the page you want to capture):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for setup and options. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and try 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Playwright’s full-page screenshot option load lazy images automatically?

No. It controls the captured page extent, not whether the page’s lazy-loading behavior has run or whether each image is ready.

Is waiting for `load` enough before a screenshot?

Not for every lazy-loaded image. The document’s load event is not a condition that each deferred image has loaded.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.