Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →With Selenium WebDriver in Python, save the current browser window as a PNG by calling browser.save_screenshot("screenshot.png"). The method returns True when Selenium writes the file and False when an I/O error prevents saving. Use a writable path whose filename ends in .png; create the parent directory first when necessary.
Minimal Selenium example
The variable can be named browser or driver; it must refer to a Selenium WebDriver instance. This complete example opens a page, creates an output directory, saves the current window, checks the result, and closes the browser.
from pathlib import Path
from selenium import webdriver
out = Path("screenshots")
out.mkdir(parents=True, exist_ok=True)
browser = webdriver.Chrome()
try:
browser.get("https://example.com")
saved = browser.save_screenshot(str(out / "page.png"))
if not saved:
raise RuntimeError("Screenshot save failed")
finally:
browser.quit()
Selenium’s WebDriver API documents save_screenshot(filename) as saving a screenshot of the current window to a PNG image file. See the Selenium 4.49.0 WebDriver API documentation.
What save_screenshot captures
The current window, not automatically the whole page
The method captures the browser’s current window or viewport. It does not promise a stitched image of everything below the fold. If a page is taller than the viewport, content outside the visible window is not covered by this Selenium call.
#1 Best Overall
The page state at the moment of the call
Navigate first, then wait for the content you need before saving. If a single-page application is still rendering, the screenshot can contain a loading state. Selenium does not automatically wait for every image, animation, network request, cookie banner, or JavaScript update.
PNG output
Use a filename ending in .png. The API is a PNG file-saving method; do not treat the extension as a request for JPEG or WebP conversion.
Paths, return values, and reliable file handling
Use a writable destination
The API reference recommends a full path and shows a relative example such as ./screenshots/foo.png. A relative path is resolved from the Python process’s current working directory. Path.mkdir(..., exist_ok=True) prevents a missing directory from causing the save to fail.
On Windows, pass a normal string created by str(path), or use a raw string for a literal absolute path:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →saved = browser.save_screenshot(r"C:workshotshome.png")
Check the Boolean result
Selenium returns False if an IOError occurs; otherwise it returns True. A truth-value check makes failures visible in test runs and scheduled jobs instead of silently continuing with a missing artifact.
filename = Path("artifacts") / "checkout.png"
filename.parent.mkdir(parents=True, exist_ok=True)
if not browser.save_screenshot(str(filename)):
raise IOError(f"Selenium could not save {filename}")
Confirm the file when a pipeline requires it
The Boolean indicates Selenium’s save operation, while a build system may also want to verify that the path exists and has nonzero size:
if not browser.save_screenshot(str(filename)) or not filename.is_file():
raise RuntimeError("Screenshot artifact was not created")
Waiting for a useful screenshot
Use an explicit wait for a meaningful page condition rather than an arbitrary long sleep. For example, wait until a main heading is visible:
Rank #2
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser.get("https://example.com")
WebDriverWait(browser, 15).until(
EC.visibility_of_element_located((By.TAG_NAME, "h1"))
)
browser.save_screenshot("screenshots/ready.png")
For content that appears after a JavaScript request, wait for a selector that represents the completed state. A fixed delay can be useful for a known animation, but it is slower and less deterministic than a condition tied to the page.
Headless browser screenshots
Selenium works with headless Chrome or another supported browser when a graphical display is unavailable. The screenshot method is unchanged; only the driver configuration differs.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless=new")
options.add_argument("--window-size=1440,900")
browser = webdriver.Chrome(options=options)
browser.get("https://example.com")
browser.save_screenshot("screenshots/headless.png")
browser.quit()
Set the window size deliberately in headless runs. Otherwise, a default viewport can produce a different layout from a developer’s desktop browser. Headless mode does not turn save_screenshot into a full-page capture.
Getting image data instead of writing a file
When an application needs to upload, hash, transform, or embed the image itself, Selenium also exposes binary and Base64 variants in the same WebDriver API.
PNG bytes
png_bytes = browser.get_screenshot_as_png()
with open("screenshots/page.png", "wb") as image_file:
image_file.write(png_bytes)
Base64 text
encoded = browser.get_screenshot_as_base64()
# Store encoded, send it to an API, or place it in a data URL.
These alternatives avoid an intermediate file. They still represent the WebDriver’s current-window screenshot scope.
When you need a full page or one element
Choose the automation library according to the capture scope you need:
| Approach | Typical call | Scope and output |
|---|---|---|
| Selenium WebDriver | browser.save_screenshot("page.png") |
Current window; writes PNG; returns Boolean |
| Playwright Python page | page.screenshot(path="page.png", full_page=True) |
Viewport or full scrollable page; can also return bytes when path is omitted |
| Playwright Python locator | Locator screenshot method | One element, written to a path or returned as bytes |
| Robot Framework Browser | Browser library screenshot keyword | Playwright-powered page or element capture; supports an output directory and custom path |
| Robot Framework Screenshot library | Screenshot library keyword | Machine-display capture, a separate workflow that may require a screenshot tool/module and a physical or virtual display |
For Playwright’s documented page, full-page, and element options, see Playwright Python screenshots. Robot Framework’s browser-library details are at the Browser library page and keyword reference 19.13.0. Do not confuse those APIs with Selenium’s browser.save_screenshot. The separate display-capture behavior is described in Robot Framework’s Screenshot library documentation.
Common failures and fixes
False is returned
- Check that the parent directory exists.
- Use an absolute path temporarily to rule out an unexpected working directory.
- Verify write permissions and that the destination is not a directory, locked file, or read-only mount.
- Ensure the filename ends in
.png.
FileNotFoundError or a missing directory
Create the directory before the call:
Path("screenshots").mkdir(parents=True, exist_ok=True)
The image shows a blank or loading page
Wait for a page-specific element, URL condition, or application-ready marker. Also verify that navigation did not fail and that the browser has not been closed before the save.
The screenshot is cropped or the layout is wrong
That is expected when the target is larger than the current window. Set a deliberate window size, or use a library with a documented full-page option such as Playwright’s full_page=True. For a single component, capture the element with an element-specific API.
Headless and headed images differ
Compare window dimensions, device scale, fonts, authentication state, and timing. Set the same viewport explicitly and wait for the same readiness condition in both modes.
Driver or browser startup errors
Resolve the WebDriver installation and browser-version compatibility first. save_screenshot runs only after a live WebDriver session has been created.
Practical patterns for tests and automation
Unique filenames
from datetime import datetime, timezone
stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
path = Path("artifacts") / f"failure-{stamp}.png"
path.parent.mkdir(exist_ok=True)
browser.save_screenshot(str(path))
Capture only on test failure
Place the save call in the test framework’s failure hook. This keeps normal runs fast while preserving the browser state that explains an assertion error. Always capture before teardown quits the driver.
Keep screenshots reproducible
- Fix the viewport size and browser mode.
- Use a stable test account and deterministic data.
- Wait for a specific ready condition.
- Mask or avoid secrets, tokens, and personal data before publishing artifacts.
- Retain the URL, test name, browser version, and timestamp alongside the image.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners before capture, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and lets you turn those steps off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and whether the request was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use the ScreenshotNeo API documentation for the complete option list. The direct call is:
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}`);
Beyond a basic viewport shot, ScreenshotNeo supports full-page captures with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF paper and page-range controls, HTML/CSS rendering, custom JavaScript and CSS, clicks, selector or network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work.
Plans include 1,000 free shots per month with no card, Starter at $5 for 3,000, Growth at $15 for 15,000, Pro at $39 for 60,000, Scale at $99 for 250,000, and Business at $249 for 1,000,000. Yearly billing provides two months free, and every feature is on every plan. Sign up free for ScreenshotNeo.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Operational and cost considerations
A local Selenium screenshot consumes browser startup time, memory, and the maintenance burden of browser and driver compatibility. It is appropriate when the page is already part of an end-to-end test, when you need authenticated browser state, or when the image must be produced inside your existing test process.
Free tools Windows power users keep installed
One-click scans. No signup required.
An API is useful for scheduled, bulk, or server-side captures without managing browsers. With ScreenshotNeo, inspect X-Page-Verdict and X-Billed so a caller can distinguish a clean billed capture from a failed or cache response. Caching can reduce repeat work when a chosen TTL is acceptable; asynchronous jobs and signed webhooks prevent long-running capture requests from blocking a worker.
FAQ
Does browser.save_screenshot save JPEG files?
No. Selenium documents this method as saving a PNG image. Convert the resulting file separately if another format is required.
Best Value
Can I call it before browser.get()?
You can call the method only after a WebDriver session exists, but a useful page capture requires navigating to the target and waiting for the desired state first.
Why does my screenshot not include content below the fold?
The Selenium method targets the current window. Use a documented full-page capability in another library, or an API designed for full-page capture, when the entire scrollable document is required.
Recommended Free Tools
Frequently Asked Questions
Does `browser.save_screenshot` save JPEG files?
No. Selenium documents this method as saving a PNG image. Convert the resulting file separately if another format is required.
Can I call it before `browser.get()`?
You can call the method only after a WebDriver session exists, but a useful page capture requires navigating to the target and waiting for the desired state first.
Why does my screenshot not include content below the fold?
The Selenium method targets the current window. Use a documented full-page capability in another library, or an API designed for full-page capture, when the entire scrollable document is required.
Quick Recap
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.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute

