Recommended Free Tools
Use driver.save_screenshot("path.png") to save the current Selenium window as a PNG. The Python binding also provides get_screenshot_as_file() (the equivalent file method), get_screenshot_as_png() for bytes, get_screenshot_as_base64() for text, and element.screenshot() for one element. Full-document capture is driver-specific; Firefox documents get_full_page_screenshot_as_file().
Choose the Selenium screenshot method
Your target and output format determine the correct syntax:
| Need | Python method | Result |
|---|---|---|
| Visible browser window saved to disk | driver.save_screenshot("shot.png") |
PNG file and a Boolean success value |
| Same file operation under its explicit name | driver.get_screenshot_as_file("shot.png") |
PNG file and a Boolean success value |
| Image for your own processing | driver.get_screenshot_as_png() |
PNG bytes |
| Embed or transmit as text | driver.get_screenshot_as_base64() |
Base64-encoded PNG text |
| One element only | element.screenshot("element.png") |
PNG file of the selected element |
| Entire document | driver.get_full_page_screenshot_as_file("full-page.png") |
Full-page PNG in Firefox’s documented API |
The first two methods capture the current browser window, not automatically the complete scrollable document. Use a full-page method where the installed driver supports it, or use a service designed for document capture.
Save the current window as a PNG in Python
Install Selenium in the environment running your test or script, start a WebDriver, navigate to the page, and save after the page state you want to record has been reached.
#1 Best Overall
from pathlib import Path
from selenium import webdriver
output = Path("screenshots/home.png")
output.parent.mkdir(parents=True, exist_ok=True)
with webdriver.Chrome() as driver:
driver.get("https://example.com")
ok = driver.save_screenshot(str(output))
if not ok:
raise OSError(f"Selenium could not write {output}")
print(f"Saved {output}")
The filename should end in .png. Selenium returns True when the file is written and False when an I/O error prevents the write. Always check that value in test automation; otherwise a missing artifact can look like a successful test.
Use the equivalent file method
save_screenshot() delegates to Selenium’s file method. Choose the explicit name when reading code that follows the WebDriver API terminology:
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://example.com")
ok = driver.get_screenshot_as_file("screenshots/example.png")
if not ok:
raise OSError("Screenshot could not be written")
Both methods write a PNG of the current window. They do not return image bytes; their return value is a Boolean indicating whether the write succeeded.
Capture PNG bytes without writing a file
When another library will resize, hash, upload, or attach the image, keep it in memory:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsRank #2
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://example.com")
png_bytes = driver.get_screenshot_as_png()
# Example: write it later, after validation or processing.
with open("screenshots/in-memory.png", "wb") as image_file:
image_file.write(png_bytes)
png_bytes is a Python bytes object containing a complete PNG. This avoids an intermediate file and lets your application decide where the data goes.
Get base64 for HTML or text transports
Use the base64 method when the image must be embedded in HTML or sent through a text-only interface:
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://example.com")
encoded = driver.get_screenshot_as_base64()
html = f'
'
with open("report.html", "w", encoding="utf-8") as report:
report.write(html)
The returned value is base64 text, not a data-URI by itself. Add the data:image/png;base64, prefix when placing it in an HTML src attribute.
Capture a single element
Element capture is useful for a component, chart, modal, or assertion target instead of the entire viewport:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://example.com")
main = driver.find_element("css selector", "main")
ok = main.screenshot("screenshots/main.png")
if not ok:
raise OSError("Element screenshot could not be written")
The selector must resolve to an element that is present in the current DOM. If your page renders it asynchronously, wait for the element before calling screenshot(). Element capture is separate from driver-level window capture and may behave differently for elements that are clipped, hidden, or covered by another layer.
Take a full-page screenshot
Ordinary save_screenshot() and get_screenshot_as_file() are documented as current-window captures. Full-document support is driver-specific. Firefox documents this method:
from selenium import webdriver
with webdriver.Firefox() as driver:
driver.get("https://example.com/long-page")
ok = driver.get_full_page_screenshot_as_file(
"screenshots/full-page.png"
)
if not ok:
raise OSError("Full-page screenshot could not be written")
Do not assume that a method available in one browser binding has identical behavior in another. If full-page output matters across Chrome, Firefox, and remote grids, verify the specific browser and driver combination used by your CI system. A window screenshot may contain only the current viewport, while a full-page implementation may stitch or otherwise render the complete document.
Make captures deterministic in tests
Wait for the page state you need
A screenshot records the instant of capture. Navigate first, then wait for a meaningful element or application state rather than relying only on a fixed sleep. This prevents images of loading spinners, empty containers, or pre-hydration markup.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Set a repeatable viewport
Responsive layouts change with window size. Set the same window dimensions in local and CI runs when pixel comparisons matter:
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.set_window_size(1440, 900)
driver.get("https://example.com")
driver.save_screenshot("screenshots/desktop.png")
Use unique, writable paths
Create the destination directory before capture and include a test name, browser, or timestamp when parallel jobs could otherwise overwrite one another. Prefer an absolute path in CI so the working directory cannot change unexpectedly.
Check the Boolean result
A successful browser command does not guarantee that the operating system accepted the file write. Handle False as a test failure and preserve the exception or path in your logs.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
False is returned |
Destination cannot be written, the directory is missing, or an I/O error occurred. | Create the directory, use a writable absolute path, keep the .png extension, and check permissions. |
| Only the visible viewport appears | save_screenshot() is a current-window capture. |
Use the documented full-page method for the selected driver, or capture a page-specific service. |
| Element lookup fails | The element has not rendered, the selector is wrong, or the frame is not selected. | Wait for the element, verify the CSS selector, and switch to the correct frame before locating it. |
| Image shows a loading state | Capture ran before asynchronous content, fonts, or images finished. | Wait for an application-ready condition or a key element, then capture. |
| Base64 image does not render | The HTML is missing the data-URI prefix or the value was altered during transport. | Use data:image/png;base64, immediately before the returned string and preserve it as text. |
| Different pixels in CI | Viewport, browser version, fonts, device scale, or page timing differs. | Standardize the environment and viewport, wait for stable content, and compare within a policy that accounts for rendering differences. |
Performance, reliability, and storage considerations
- Disk versus memory: file methods are convenient for test artifacts; bytes avoid temporary files but consume process memory until released.
- PNG size: screenshots can be large, especially at high viewport dimensions. Retain only the artifacts needed for debugging and apply your normal storage lifecycle.
- Parallel execution: use per-test filenames or directories to prevent workers from replacing one another’s captures.
- Remote WebDriver: the screenshot command runs through the WebDriver session, while the destination path belongs to the process writing the returned artifact. Make sure that process has a writable filesystem.
- Timing: deterministic waits usually improve reliability more than repeated retries after a premature capture.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF without maintaining a Selenium browser session. The API can accept consent banners before capture and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.
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 request options. The same endpoint is callable from Python:
Best Value
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And from 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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets or a custom viewport, retina scale, PDF paper and page controls, custom CSS and JavaScript, clicks, waits, ad and tracker blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
| 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 |
Yearly billing gives two months free, and every feature is available on every plan. Start with 1,000 free screenshots a month without adding a card.
Frequently Asked Questions
Does Selenium save screenshots as JPEG or WebP?
The documented Python driver methods save PNG files. Convert the returned PNG bytes with an image-processing library if another format is required.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Can I use a screenshot as a test attachment?
Yes. Save the PNG to the artifact directory, or attach the value returned by get_screenshot_as_png() directly through your test runner’s attachment API.
Is a full-page screenshot guaranteed in every Selenium browser?
No. The documented full-document method is driver-specific; ordinary driver screenshot methods describe the current window. Verify support for the browser and driver you run.
What should I name the screenshot file?
Use a writable path ending in .png. In parallel or repeated runs, include a test identifier and browser name to avoid collisions.
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.

