October 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 ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Take a Screenshot After a Page Finishes Loading in Selenium (Python)

Use Selenium’s default navigation wait for document readiness, then add a targeted explicit wait when the screenshot depends on content rendered later by JavaScript.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call driver.save_screenshot("page.png") only after Selenium has reached the readiness condition your image needs. A normal driver.get() waits for document readiness by default, but pages that render content later with JavaScript need an explicit wait for that content.

Capture after the right loading condition

For a static page, Selenium’s default navigation behavior is often enough: with the normal page-load strategy, navigation waits until the document’s readyState is complete. That does not guarantee that a single-page app, API-backed result, or other asynchronously updated component has finished rendering. For those pages, wait for a page-specific condition that represents what should appear in the screenshot.

As an Amazon Associate I earn from qualifying purchases.

The example below waits for a results element to become visible, then saves the current browser window as a PNG. The selector and 15-second timeout are examples; replace them with a locator and timeout appropriate to the site.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

with webdriver.Chrome() as driver:
    driver.get("https://example.com")

    # Replace this selector with an element that appears when the content is ready.
    WebDriverWait(driver, 15).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, "main .results"))
    )

    driver.save_screenshot("page.png")

Selenium’s official Browser Options and Waiting Strategies documentation distinguish document loading from later application updates. The Python API documents save_screenshot() as saving the current window to a PNG file; use get_screenshot_as_png() if you need the screenshot as binary image data instead of writing a file directly (Selenium Python WebDriver API).

What Selenium means by “page loaded”

Default: normal

The default normal strategy waits for the document readiness state complete during URL navigation. Selenium’s options guide says this waits for resources to download, but a modern application may continue changing the page afterward. Use the default when the elements you need are present by document readiness.

Alternative navigation thresholds: eager and none

The session-level eager strategy returns at the interactive / DOMContentLoaded threshold, while some resources, including images, may still be loading. none does not block navigation on document readiness. These options change when navigation returns; they do not confirm that a particular widget, image, or application update is ready for capture. Even with either strategy, wait explicitly for the application state you need.

Choose a wait that matches the screenshot

  • Static page: Rely on the default navigation wait if the desired content exists by document readiness, then capture.
  • Single-page app or API-backed content: Wait for the relevant element to appear or become visible before capture.
  • After a click: Wait for the resulting state or element, rather than assuming the click itself means the update has finished.
  • Images or other specific assets: Choose an observable condition that indicates the asset you need is ready. Document readiness alone may not cover later application activity.

An explicit wait polls for its condition until it succeeds or times out. This is generally more reliable than inserting an arbitrary fixed sleep because the capture is tied to an observable page state, not an assumed duration.

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

Timeouts and common failures

The explicit wait times out

A timeout means Selenium did not observe the requested condition within the allotted time. Check that the locator matches the current page, that the element is expected to become visible rather than merely exist, and that navigation or an overlay has not changed the relevant context. Increase the timeout only if the page legitimately needs more time; a longer timeout will not correct a wrong locator or condition.

Navigation raises a page-load timeout

A page-load timeout limits how long the driver waits for navigation. It is not a signal that asynchronous application work is complete. Decide separately what navigation threshold is acceptable and what page-specific condition the screenshot requires.

The screenshot is missing late content

If the image is captured after driver.get() but before a JavaScript-driven update, add an explicit wait for the intended result or state. Avoid treating a shorter navigation threshold such as eager or none as a substitute for that wait.

Wait durations behave unpredictably

Selenium warns that combining implicit and explicit waits can lead to unpredictable wait durations. For this workflow, use a targeted explicit wait for the screenshot condition instead of mixing wait styles casually.

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

Or skip the browser setup

If you need an image from a URL without managing a Selenium browser session, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot or PDF. Here is a cURL example; see the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Responses include X-Page-Verdict and X-Billed headers.
  • Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.

Frequently Asked Questions

Does Selenium wait for the page to load before taking a screenshot?

With the default `normal` strategy, URL navigation waits for document readiness to reach `complete`. A JavaScript application may still update afterward, so wait for the content you need.

Should I use `time.sleep()` before saving a screenshot?

A fixed sleep is not tied to page state. Use an explicit wait for the relevant element or condition so capture proceeds when that condition succeeds or reports a timeout.

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.

Can Selenium save a screenshot as something other than a PNG file?

The documented `save_screenshot()` method writes a PNG file. `get_screenshot_as_png()` returns binary PNG data; the cited Python API does not establish other output formats for these methods.

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
Crashes, No Sound, or Screen Glitches?Free driver scan
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.