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

For a reliable bulk run, use one controlled Selenium WebDriver session to process URLs sequentially: set a consistent viewport, open each page, wait for the content you need, save a uniquely named PNG, record success or failure, and always quit the driver. Selenium’s standard Python screenshot method captures the current browser window—not automatically the entire document—so choose the capture extent before you build the workflow.

Choose the capture type before processing a batch

“Screenshot” can mean different outputs. Selenium documents screenshots of the current window and of individual elements; its Python API also exposes screenshot bytes and base64 forms for application-managed output. A current-window PNG is the simplest choice for a batch of consistent viewport captures. Selenium’s WebDriver guide covers window and element screenshots.

  • Current window: captures what is visible in the browser window. Python’s save_screenshot writes a PNG and returns a success value that you should check. See the Selenium Python WebDriver API.
  • One element: use an element screenshot when the deliverable is a specific component rather than the whole viewport. Selenium’s guide includes element screenshot examples.
  • Full document: do not assume the regular current-window method captures an entire long page. Selenium’s Firefox Python API documents save_full_page_screenshot and related full-document methods; the cited API documentation does not establish equivalent native full-page support for every browser driver. Check the Firefox API reference and verify the current official API for your chosen driver.

Prepare a repeatable batch

Set the inputs and output scheme

Keep the URLs in a fixed list or input file, and decide how output names will be generated before the run. Use an index in the filename so repeated URLs cannot overwrite one another. Save a manifest containing each URL, its result, and its output path; this makes partial failures easier to rerun and audit.

Choose viewport and execution mode

Set the same window dimensions before navigating to pages if screenshots need to be comparable. Selenium’s remote WebDriver API documents window sizing. The API reference also documents current-window screenshot saving. Selenium’s guide shows a Chrome headless-options example, so headless operation is an available unattended setup to consider. Validate rendering, fonts, and viewport behavior in the browser and deployment environment you will actually use. See the official guide.

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.

Define what “ready” means for the page

A successful navigation does not necessarily mean that asynchronous content, images, or application data have finished rendering. Wait for the signal that matters to the screenshot: for example, a known page element becoming visible or a loading indicator disappearing. Use a fixed delay only when the page has no better readiness signal, and treat it as a practical compromise rather than proof that all content has settled. Lazy-loaded sections, animations, cookie banners, and infinite scrolling need page-specific handling; the cited Selenium API documentation does not prescribe a universal solution for them.

Run a sequential batch in Python

This example uses one Chrome session sequentially, creates deterministic output names, waits for document readiness, and writes a CSV manifest. The readiness wait is intentionally generic: for pages with asynchronous content, replace or supplement it with a wait for the specific element or state required in the image.

from pathlib import Path
import csv

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

urls = [
    "https://example.com",
    "https://example.org",
]

out_dir = Path("screenshots")
out_dir.mkdir(parents=True, exist_ok=True)
manifest_path = out_dir / "manifest.csv"

options = webdriver.ChromeOptions()
options.add_argument("--headless")

driver = webdriver.Chrome(options=options)
rows = []

try:
    driver.set_window_size(1440, 1000)

    for index, url in enumerate(urls, start=1):
        output_path = out_dir / f"page-{index:04d}.png"
        status = "saved"
        error = ""

        try:
            driver.get(url)
            WebDriverWait(driver, 30).until(
                lambda browser: browser.execute_script(
                    "return document.readyState"
                ) == "complete"
            )

            saved = driver.save_screenshot(str(output_path))
            if not saved:
                status = "write_failed"
                error = "save_screenshot returned False"
        except Exception as exc:
            status = "failed"
            error = f"{type(exc).__name__}: {exc}"

        rows.append({
            "url": url,
            "status": status,
            "output_path": str(output_path) if status == "saved" else "",
            "error": error,
        })
finally:
    driver.quit()

with manifest_path.open("w", newline="", encoding="utf-8") as manifest_file:
    writer = csv.DictWriter(
        manifest_file,
        fieldnames=["url", "status", "output_path", "error"],
    )
    writer.writeheader()
    writer.writerows(rows)

print(f"Wrote {len(rows)} results to {manifest_path}")

Install Selenium in the Python environment used to run the script with python -m pip install selenium. Selenium documents save_screenshot as saving the current window to a PNG; its filename should end in .png, and the method returns False on an IOError. Checking that return value catches a file-write failure that would otherwise look like a successful page capture. Python WebDriver API reference.

The example catches page-level errors and continues to the next URL, then quits the browser in a finally block. Its manifest is written after the loop; if preserving results despite a process crash is essential, write or flush manifest rows incrementally. The document.readyState check is not a guarantee that a modern page’s dynamic content has finished loading.

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

Scale cautiously and preserve useful output

A single session processing URLs one after another is the simplest batch architecture and avoids concurrent sessions competing for the same machine resources. If throughput requires parallel work, use isolated sessions and explicit ownership of output paths, then increase the worker count gradually while measuring the actual browser host. Selenium’s cited documentation gives no universal worker count, throughput rate, or memory requirement, so a number that works for one page mix or machine is not a general capacity guarantee.

For a remote WebDriver or Grid run, decide where screenshots will be stored and how the calling process will retrieve them. A path on a remote browser node is not necessarily a path on the machine running your batch script; storage and retrieval depend on the deployment arrangement.

Troubleshoot common batch failures

  • The screenshot is cut off: the ordinary current-window method captures the visible window, not necessarily the full document. Decide whether you need a viewport, element, or full-document image and select an API that documents that capture type for your driver.
  • The screenshot shows a spinner or missing content: navigation completion may precede application rendering. Wait for the required element or for a known loading indicator to disappear. If content loads only after scrolling, handle that page-specific behavior before saving.
  • Some pages overwrite others: URL-derived names can collide when URLs repeat or normalize to the same key. Include a stable batch index or another unique identifier in each filename.
  • A PNG is missing despite no navigation error: check the boolean returned by Python’s save_screenshot, confirm the destination directory exists and is writable, and inspect the manifest’s write status.
  • The run stops after one bad URL: catch exceptions around each page, record the URL and error, and continue; keep driver cleanup in finally so a failed page does not leave the session running.
  • Headless output differs from local output: compare the configured viewport and browser environment, then validate fonts and rendering in the target deployment. The official guide demonstrates Chrome headless configuration, but that example is not a guarantee of identical rendering across environments. Selenium guide.
  • Parallel jobs are unstable: reduce concurrency and measure CPU, memory, and browser stability on the actual host. There is no universal concurrency recommendation established by the cited Selenium API pages.
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 screenshots from URLs without managing WebDriver sessions, ScreenshotNeo is a website screenshot API and MCP server. Its API accepts one GET request with a URL and can return PNG, JPEG, WebP, or PDF. For a single image request, use cURL:

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

See the ScreenshotNeo API documentation for parameters and response details. ScreenshotNeo’s stated features include removing cookie/consent banners, newsletter popups, and chat widgets before capture, with each cleanup step switchable; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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.