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 desk3 min

How to Capture Multiple Website Screenshots with Selenium in Python for Bulk Testing

A repeatable Selenium pattern for bulk viewport screenshots: one driver session, controlled sizing, readiness waits, unique PNG paths, and visible failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use one Selenium WebDriver session, loop through your URLs, wait for each page to reach the state your test needs, and save the current browser window to a distinct PNG file with driver.save_screenshot(). Set a consistent viewport and close the driver in a finally block so the run stays repeatable and the browser is shut down even when a capture fails.

Capture a list of URLs with one Selenium session

This example saves one viewport screenshot per URL. It creates the output directory, gives each file a unique index and hostname, checks Selenium’s save result, and always quits the driver.

from pathlib import Path
from urllib.parse import urlparse
from selenium import webdriver

urls = [
    "https://example.com/",
    "https://www.selenium.dev/",
]

output_dir = Path("screenshots")
output_dir.mkdir(parents=True, exist_ok=True)

options = webdriver.ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
driver.set_window_size(1440, 1000)

try:
    for index, url in enumerate(urls, start=1):
        driver.get(url)
        # Wait for the application state your test needs before capturing.
        host = urlparse(url).netloc.replace(":", "_") or "page"
        path = output_dir / f"{index:03d}_{host}.png"
        saved = driver.save_screenshot(str(path))
        if not saved:
            print(f"Screenshot save failed: {url} -> {path}")
finally:
    driver.quit()

Selenium documents save_screenshot(filename) as saving the current window to a PNG and returning a Boolean; it recommends a full path ending in .png. A false return signals an I/O error. The method captures the current window, not a guaranteed full-page image. See the Selenium Python WebDriver API.

The example’s index prevents repeated hostnames from overwriting one another. If your list can contain the same URL more than once, include a run ID or other unique identifier in each filename. Hostnames are illustrative; for arbitrary URLs, sanitize path components before using them as filenames.

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.

Make captures useful for bulk testing

Keep the test conditions consistent

Set the viewport deliberately before the loop. For visual comparisons, also hold the browser version, test data, relevant user state, and page-readiness condition steady. Otherwise, differences between images may come from the capture environment or changing page content rather than the code under test.

Wait for the condition you are testing

Navigation completing does not necessarily mean that a single-page application, image, or asynchronously loaded component is ready. Replace the comment in the example with a condition-based wait for the target view—for example, wait for the specific element or state that signals the tested screen is ready. Avoid relying on an arbitrary short sleep when a meaningful application condition is available.

Report failures and shut down cleanly

Check the Boolean returned by save_screenshot and record the URL and destination for failed saves. Navigation or wait failures can also interrupt a batch, so catch and log per-URL exceptions if you want later URLs to continue; decide whether the test should ultimately fail when any page fails. Keep driver.quit() in finally so it runs after both success and exceptions. Selenium’s documentation also demonstrates shutting down the driver after capture in its windows and tabs guide.

Choose Selenium or Chrome’s headless command line

Route Best fit Trade-off
Selenium Python WebDriver Bulk tests that need browser interactions, state setup, or per-URL automation. Requires a browser-driver session and test-specific readiness logic; the documented screenshot is of the current window.
Chrome headless command line A simple URL capture with an explicit viewport size. The documented command-line capture does not provide Selenium’s programmed test loop or interaction workflow.

Chrome’s headless command-line reference documents --screenshot and an example using --window-size=412,892. Use Selenium when the test must prepare or interact with pages; a command-line capture may suit a simpler one-off URL. In either route, verify what capture scope and page state your particular workflow needs.

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

Or skip the browser setup

ScreenshotNeo provides a screenshot API and MCP server for developers. Its one-call GET request accepts a URL and returns an image or PDF. For a PNG capture:

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

See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Selenium’s save_screenshot() capture a full webpage?

No. Selenium documents it as capturing the current window; this method alone does not promise a full-page screenshot.

What does a false result from save_screenshot() mean?

The Selenium API documents the Boolean return as false on an I/O error, so check the output path and record the failed save.

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

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. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
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.