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 DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Take Website Screenshots with Selenium and Chromium

Use Selenium’s save_screenshot for a Chromium window, element.screenshot for a specific element, or BiDi capture for viewport and document screenshots.

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.

For a PNG of the current browser window, navigate with Selenium and call driver.save_screenshot("screenshot.png"). Use element.screenshot(...) when you need one element, and Selenium’s Python BiDi capture API when you need to request a viewport or document screenshot. The right method depends on the capture scope and the Selenium/browser versions you have installed.

Capture the current browser window with Selenium

This Python example starts Chromium through Selenium, opens a page, saves the current-window screenshot as a PNG, checks whether saving succeeded, and closes the driver even if navigation or capture raises an error.

As an Amazon Associate I earn from qualifying purchases.

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless=new")  # Optional: run without a visible browser window.

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    ok = driver.save_screenshot("screenshot.png")
    if not ok:
        raise OSError("Screenshot could not be saved")
finally:
    driver.quit()

The Selenium guide documents the webdriver.Chrome() and save_screenshot('./image.png') workflow. The headless option is optional; Selenium’s Chrome guide shows passing arguments through ChromeOptions, including --headless=new. Selenium WebDriver documentation and Chrome-specific guidance describe these APIs and setup.

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

save_screenshot(path) writes a PNG of the current window and returns False if there is an I/O error. The example turns that return value into an explicit error so a failed write is not silently treated as success. You can also retrieve screenshot data as bytes with driver.get_screenshot_as_png(), or use the screenshot APIs that return Base64 data when that representation fits your workflow. See the Selenium Python Chromium WebDriver API.

Choose the screenshot scope you need

Need Python API What it captures
Ordinary screenshot driver.save_screenshot("screenshot.png") Current browser window, saved as PNG.
One element element.screenshot("element.png") The located element, saved as a separate image.
Viewport or document capture driver.browsing_context.capture_screenshot(...) BiDi screenshot data requested with a viewport or document origin; the method returns Base64 data.

Capture one element

Locate the element you want, then call its screenshot method. For example, after creating driver and navigating to a page:

from selenium.webdriver.common.by import By

element = driver.find_element(By.CSS_SELECTOR, "main")
ok = element.screenshot("main.png")
if not ok:
    raise OSError("Element screenshot could not be saved")

This is useful when the output should be limited to a specific element rather than the whole current window. Selenium’s official guide demonstrates the Python element screenshot pattern: Selenium WebDriver documentation.

Request a viewport or whole-document screenshot with BiDi

Selenium’s Python BiDi browsing-context API accepts an origin of "viewport" or "document", an optional clip rectangle, and returns Base64 screenshot data. The following is the capture call shape; it assumes BiDi support is enabled for the driver and that you have the relevant browsing-context identifier:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
encoded = driver.browsing_context.capture_screenshot(
    context=context_id,
    origin="document",  # Or "viewport"
)

This is a BiDi API, not a drop-in spelling of save_screenshot. Check the API documentation for your installed Selenium version and browser before using it; setup and support can vary. The documented Python method and parameters are in the Selenium Python BiDi browsing-context API.

Wait for the page state you actually need

driver.get(url) waits until the page’s onload event fires. That does not guarantee that asynchronous JavaScript, lazy-loaded images, animations, or fonts have finished changing the visual page. For a repeatable capture, wait for a page-specific signal—for example, a known element or application state—rather than assuming a fixed sleep or the load event means the page is visually settled. The navigation behavior is documented in the Selenium Python Chromium WebDriver API; the readiness condition should be chosen for the site you are capturing.

Set up Chromium and keep versions aligned

Selenium’s Chrome-specific documentation says Selenium 4 is compatible with Chrome 75 and greater and advises that Chrome and ChromeDriver have the same major version. Configure browser arguments with ChromeOptions, and check the documentation for the Selenium release installed in your environment when reproducing a setup: Selenium Chrome documentation.

Troubleshoot common screenshot problems

  • The screenshot file is missing or cannot be opened: Check the destination path and whether the process can write there. save_screenshot returns False on an I/O error; check the result instead of assuming a file was produced.
  • The capture shows a loading state or incomplete content: Navigation’s onload wait does not establish that asynchronous content, lazy images, fonts, or animations have settled. Wait for a site-specific element or state before capturing.
  • Chrome fails to start or the driver cannot control it: Check that Chrome and ChromeDriver have matching major versions, and confirm that the installed Selenium release supports your setup.
  • The whole page is not included: The ordinary save_screenshot method captures the current window. For a document-origin capture, use the separate BiDi API and verify that it is available in your installed Selenium/browser versions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

The documented APIs establish capture scope and output formats, not a universal capture time or identical visual fidelity across websites, operating systems, browser versions, and page lengths. Actual results depend on the page and environment. For reliable automated work, make readiness conditions specific to the page, handle file-write failures, and always close the driver after use. The example’s finally block is ordinary Python cleanup practice, not a guarantee that every browser or page will behave identically.

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

Selenium and Chromium are software APIs; the cited documentation does not establish a per-screenshot service price. Cost depends on the environment in which you run the browser and any infrastructure you provide.

Or skip the browser setup

If you need a hosted screenshot instead of managing Selenium and Chromium, ScreenshotNeo takes a screenshot or PDF with one GET request. Cookie and consent banners are accepted like a visitor and 60+ known consent platforms, newsletter popups, and chat widgets are removed before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response reports the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

Example cURL request, using the documented API shape:

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 parameters and setup. Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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. 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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.