Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Wait for Images Before Taking a Selenium Screenshot

A Selenium page-load completion is not proof images are ready. Wait for the relevant image state with a finite explicit timeout before capturing.

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.

Wait for the image state your screenshot actually needs, then capture. For ordinary <img> elements, a useful success check is img.complete && img.naturalWidth > 0, run inside a Selenium explicit wait with a finite timeout. This checks for available image data rather than merely a completed load attempt.

Why Selenium’s page-load completion is not enough

A completed navigation does not guarantee that every image visible in a screenshot is ready. Selenium’s navigation wait normally uses document.readyState set to complete, but JavaScript can continue changing the page or adding content afterward. That can leave screenshot code racing the page’s rendering work. See Selenium’s Waiting Strategies.

As an Amazon Associate I earn from qualifying purchases.

An explicit wait repeatedly checks a condition and continues when it becomes true or the timeout expires. Choose a condition tied to the images and page state that matter to the capture, rather than assuming driver.get() means the page has settled.

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

Wait for ordinary images in Python

This runnable pattern waits up to 15 seconds for all current document images to finish loading successfully, then saves a PNG screenshot:

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

url = "https://example.com"
driver = webdriver.Chrome()

try:
    driver.get(url)
    wait = WebDriverWait(driver, 15)
    wait.until(lambda d: d.execute_script("""
        return Array.from(document.images).every(
            img => img.complete && img.naturalWidth > 0
        );
    """))
    driver.save_screenshot("page.png")
finally:
    driver.quit()

Replace https://example.com with the page under test. The script checks the images in the current document when each poll runs. Selenium’s explicit waits and JavaScript execution are documented in its wait guidance and JavaScript WebDriver API.

What the two image properties mean

complete indicates that the image’s loading process has completed; it does not by itself prove the image loaded successfully. naturalWidth is the intrinsic, density-corrected width, and is zero when image data or intrinsic width is unavailable. Requiring both properties makes the condition useful when the screenshot needs actual image data. See MDN’s references for HTMLImageElement.complete and HTMLImageElement.naturalWidth.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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

Wait only for images in the capture area

If the page contains unrelated, decorative, or intentionally broken images, requiring every image to succeed may be too strict. Select the relevant region instead:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wait.until(lambda d: d.execute_script("""
    const images = [...document.querySelectorAll("main img")];
    return images.length > 0 && images.every(
        img => img.complete && img.naturalWidth > 0
    );
"""))
driver.save_screenshot("main.png")

The nonempty check matters: JavaScript’s every() returns true for an empty array. Keep images.length > 0 if the screenshot is invalid without a matching image; omit it when an empty selection is acceptable.

Rank #3
Sale
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.

Handle lazy-loaded images before waiting

Some pages request images only when their region approaches or enters the viewport. A check performed before visiting that region cannot establish that those images were requested. Scroll through the portion the screenshot must include to trigger the page’s loading behavior, then wait for the relevant image condition. For a full-page capture, the exact scrolling strategy depends on the page’s implementation; recheck the condition just before capture.

Choose a failure policy and diagnose timeouts

The all-success condition deliberately times out if even one selected image fails or has no usable intrinsic width. Decide whether that should fail the screenshot workflow or whether failed images are acceptable test results.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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
  • Failures should fail the capture: keep the positive-naturalWidth condition and let the explicit wait time out. Report the URL and image state in your test diagnostics if you need to identify the culprit.
  • Failures are expected but images must settle: wait for all selected images to reach complete, then separately inspect which have naturalWidth equal to zero. Treat those as reported failures rather than successful image loads.
  • The page replaces images dynamically: wait for the application state transition that triggers replacement, then evaluate the image condition again immediately before taking the screenshot.

A finite timeout, such as the 15 seconds in the example, prevents an indefinitely blocked test. Set it to suit the application and test environment; the example is not a guarantee that a particular page will load within that period.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the right frame and rendering type

Images inside an iframe

The script runs in the currently selected browsing context. A query in the top-level document does not inspect a separate iframe’s document. Switch to the frame containing the images, run the wait there, and return to the default content when finished. Selenium documents the process in its frames guide.

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.

CSS backgrounds, canvas, and video

document.images covers HTML image elements, not CSS background images, canvas-drawn content, video frames, or every application-specific rendering process. For those, wait on the relevant element or application signal instead—for example, the state that indicates a chart has rendered or a video frame is ready. A successful <img> scan cannot establish that those other content types are settled.

Capture the intended screenshot

After the wait, use the screenshot method that matches the test: a driver screenshot for the browser view or the element screenshot API for one target element. Selenium’s browser-window documentation demonstrates driver and element screenshots: Windows and tabs. Capture extent and output behavior can depend on the Selenium binding, browser, and screenshot method, so verify that the chosen API captures the intended area.

Why not use a fixed sleep or implicit wait?

A fixed sleep always pauses for the same duration: a short pause may finish too early, while a long pause wastes time when the page is ready sooner. Selenium recommends condition-based explicit waits and warns against mixing implicit and explicit waits because their combined timing can be unpredictable. Use an explicit wait for the image condition rather than adding arbitrary sleeps.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Or skip the browser setup

If you need a screenshot API rather than a Selenium workflow, ScreenshotNeo returns a screenshot or PDF from one GET request. Its clean-shot options accept consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents.

Example cURL request (see the ScreenshotNeo API documentation):

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

The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan.

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.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.