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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

In Python, open a Chrome WebDriver session, navigate with driver.get(), then call driver.save_screenshot('screenshot.png'). Selenium writes the current browsing window as a PNG and returns a Boolean that lets your script detect a file-write failure. Always quit the driver in a finally block.

Minimal working example

Install Selenium in the environment that will run the script:

python -m pip install selenium

Then save this as capture.py:

from selenium import webdriver

 driver = webdriver.Chrome()
 try:
     driver.get("https://example.com")
     saved = driver.save_screenshot("screenshot.png")
     if not saved:
         raise OSError("Could not save screenshot")
 finally:
     driver.quit()

Remove the extra leading spaces before driver and the indented lines when copying; the valid Python is:

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

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    saved = driver.save_screenshot("screenshot.png")
    if not saved:
        raise OSError("Could not save screenshot")
finally:
    driver.quit()

webdriver.Chrome() creates the Chrome session. get() navigates to the target, and save_screenshot() captures the current window after that navigation. Selenium’s Chromium WebDriver API documents the filename and Boolean return behavior in its Python API reference.

#1 Best Overall
Sale
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

What Selenium captures

Current window, not an automatically defined full-page image

The documented save_screenshot() operation captures the current browsing context/window. The official material used for this guide establishes current-window and element capture, but does not establish a Chrome-specific full-page method, viewport-size guarantee, or identical behavior between headed and headless sessions. Treat the PNG as a screenshot of the window Selenium is controlling rather than promising a complete document image.

Use a full path when the location matters

Pass a path ending in .png. A relative path is resolved from the process’s working directory, which can differ between a terminal, an IDE, a test runner, and CI. Resolve an absolute path when another step must find the file reliably:

from pathlib import Path
from selenium import webdriver

output = (Path.cwd() / "artifacts" / "home.png").resolve()
output.parent.mkdir(parents=True, exist_ok=True)

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    if not driver.save_screenshot(str(output)):
        raise OSError(f"Screenshot could not be written to {output}")
finally:
    driver.quit()

The method returns True when Selenium reports success and False when an I/O error prevents the file from being saved. Checking the value is useful in build scripts and tests instead of assuming that a call which did not raise an exception produced an artifact.

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

Choose the output form you need

Method Scope Result Use it when
driver.save_screenshot(path) Current window PNG file and a Boolean status You need a file on disk.
driver.get_screenshot_as_file(path) Current window PNG file and a Boolean status You prefer the explicit “as file” method name.
driver.get_screenshot_as_png() Current window PNG bytes The next step uploads, hashes, transforms, or stores the image in memory.
driver.get_screenshot_as_base64() Current window Base64-encoded image text A consumer requires an encoded string, such as an HTML embedding.

These methods represent the same current-window capture scope with different destinations. The underlying WebDriver screenshot response is Base64-encoded; the Python methods expose either a file, decoded PNG bytes, or Base64 text.

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

Save directly with get_screenshot_as_file()

from selenium import webdriver

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    if not driver.get_screenshot_as_file("page.png"):
        raise OSError("PNG file was not saved")
finally:
    driver.quit()

Keep PNG bytes in memory

from selenium import webdriver

 driver = webdriver.Chrome()
 try:
     driver.get("https://example.com")
     png_bytes = driver.get_screenshot_as_png()
     if not png_bytes:
         raise OSError("No PNG bytes returned")
     # Send png_bytes to your image-processing or storage code.
 finally:
     driver.quit()

As with the first example, remove the accidental leading spaces before copying this snippet into a Python file.

Request Base64 text

from selenium import webdriver

 driver = webdriver.Chrome()
 try:
     driver.get("https://example.com")
     encoded = driver.get_screenshot_as_base64()
     if not encoded:
         raise OSError("No Base64 screenshot returned")
 finally:
     driver.quit()

Base64 is text rather than a second image format. A recipient must decode it to recover the PNG data.

Capture one element instead of the window

When the artifact is a card, chart, logo, or other component, locate that element and use its screenshot method rather than capturing the whole current context:

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.
from selenium import webdriver

 driver = webdriver.Chrome()
 try:
     driver.get("https://example.com")
     card = driver.find_element("css selector", "main article")
     if not card.screenshot("article.png"):
         raise OSError("Element screenshot was not saved")
 finally:
     driver.quit()

Replace main article with a selector that identifies the element you need. An element screenshot has a different scope from driver.save_screenshot(): the driver method is for the current window, while the element method targets the selected element.

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.

A repeatable capture procedure

  1. Prepare Chrome and Selenium. Install Selenium in the same Python environment that runs the script and ensure Chrome can start under the account executing it.
  2. Create one driver session. Construct webdriver.Chrome() and keep the object available until all required captures finish.
  3. Navigate. Call driver.get(url) with the exact page URL.
  4. Select a scope. Use driver.save_screenshot() or get_screenshot_as_file() for the current window; locate an element and call its screenshot method for a component.
  5. Select a destination. Use a writable, absolute path for a file, PNG bytes for in-memory processing, or Base64 text for an encoded transport.
  6. Check the result. Test the Boolean returned by file methods, or verify that the bytes/text result is non-empty.
  7. Close the session. Put driver.quit() in finally so a failed navigation or write does not leave Chrome running.

Troubleshooting

Chrome WebDriver does not start

If webdriver.Chrome() raises a session-creation error, verify that Chrome is installed and can launch for the current user, that Selenium is installed in the active interpreter, and that the browser-driver components are compatible. Run the smallest possible script first; only add selectors or output handling after the session opens.

The script runs but no file appears

Print or log the absolute path you passed. A relative path may have been written to the test runner’s working directory rather than the project directory. Check that the parent directory exists and that the process has write permission. For a file method, handle a returned False as a failed capture instead of treating it as success.

The image shows the wrong page

Capture only after the intended driver.get() call and confirm that the URL passed to the browser is the one you expect. If your application changes content after navigation, arrange the synchronization your application requires before taking the shot; the screenshot call records the state present at the moment it executes.

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.

An element screenshot raises a lookup error

The selector may not match the current document. Confirm the element’s selector in the page under test and make sure the capture occurs after the relevant page has loaded. If the selector can match multiple nodes, narrow it to the component that should be saved.

Rank #4
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

The result is empty or unusable

For file methods, check the Boolean result. For byte and Base64 methods, check that the returned value is non-empty before handing it to another system. Preserve the original bytes when possible; converting repeatedly between bytes and encoded text adds work without changing the documented PNG output.

You need a full-page or headless guarantee

The official evidence covered here does not establish a Chrome-specific full-page screenshot API, a maximum page-height behavior, or equivalence between headed and headless sessions. Do not infer those guarantees from the current-window method. If your requirement is specifically a full document image, validate the exact Chrome/Selenium version and technique in your own environment before depending on it.

Reliability and performance considerations

  • Reuse a session for related pages. Creating and quitting Chrome is separate overhead from writing an image. Capture the pages you need, then quit once.
  • Prefer bytes for pipelines. get_screenshot_as_png() avoids a temporary file when the next operation is an upload or image transform.
  • Use files for audit trails. An absolute, deterministic path makes test artifacts easier to collect and inspect.
  • Keep cleanup unconditional. A finally block limits orphaned browser processes when navigation, element lookup, or file writing fails.
  • Keep scope explicit. Driver capture and element capture produce different artifacts; choose before you build downstream comparisons.
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 only need a URL rendered to an image or PDF, ScreenshotNeo is an API alternative to try first: it removes consent banners, newsletter popups, and chat widgets before capture, bills only clean shots, and has a $5 paid plan for 3,000 shots.

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

One GET request returns a PNG, JPEG, WebP, or PDF. The API response identifies the outcome with X-Page-Verdict and X-Billed headers. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing.

For parameters and the full option list, see the ScreenshotNeo documentation.

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.

cURL

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' }); const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Options when Selenium is more than you need

ScreenshotNeo supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper size/margins/orientation/page ranges, HTML/CSS-to-image, custom CSS and JavaScript, pre-capture clicks, hidden selectors, waits for a selector or delay or network idle, request/resource blocking, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable-TTL caching, signed public image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.

AI workflows can use its MCP server with take_screenshot, get_page_info, and capture_pdf tools from Claude, Cursor, or another MCP client.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I put a Selenium screenshot directly into an HTML page?

Yes. Use driver.get_screenshot_as_base64() when the receiving HTML needs an encoded image string, then place that value in the appropriate data URL or image attribute. The encoded value represents PNG data; it is not a separate image format.

Does Selenium’s standard Chrome call create a PDF?

No. The screenshot methods documented here produce a PNG file, PNG bytes, or Base64-encoded PNG text. A PDF is a separate output requirement; ScreenshotNeo’s API provides PDF output when that is the artifact you need.

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.