Direct answer: Selenium can save a PNG of the current browser window with driver.save_screenshot('/full/path/image.png'). Check its Boolean return value, use an absolute path when the destination must be predictable, and call element.screenshot() when you need only one element.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.example.com")
if not driver.save_screenshot("./image.png"):
raise OSError("Could not save screenshot")
driver.quit()
What Selenium’s screenshot call captures
The WebDriver screenshot API is built in; a separate screenshot utility is not required for the basic task. Selenium’s API describes the operation as capturing a screenshot for the current browsing context. In practical terms, driver.save_screenshot() captures what the active WebDriver window can currently render.
The documented file output is PNG. The API reference also exposes PNG bytes and a Base64 representation, so you can choose between a file, binary data in memory, or text suitable for embedding.
Do not assume that the basic call captures an entire scrollable document. The available documentation does not establish cross-browser full-page behavior. If you need a full-page image, verify the exact browser and Selenium feature you plan to use rather than treating the normal window screenshot as a guaranteed document-length capture.
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 →#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
Prerequisites and a predictable setup
- Install Selenium for Python. In a virtual environment, run
python -m pip install selenium. - Have a browser available. The example uses Chrome through
webdriver.Chrome(). Your browser and WebDriver setup must be usable before the capture call runs. - Choose a writable destination. Create the output directory first, or use a path that already exists and is writable by the Python process.
A relative path such as ./image.png is resolved from the process’s current working directory. Use an absolute path when a scheduled job, test runner, or CI workspace must always know where the file will be written.
Save a screenshot of the current browser window
Minimal example
This is the shortest complete flow: create the driver, navigate, save the PNG, and close the browser.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.example.com")
driver.save_screenshot("./image.png")
driver.quit()
save_screenshot(filename) returns True when the file operation succeeds and False when Selenium encounters an I/O error. For code that must fail loudly instead of silently producing a missing artifact, test that value.
from selenium import webdriver
output = "/full/path/to/screenshot.png"
driver = webdriver.Chrome()
try:
driver.get("https://www.example.com")
saved = driver.save_screenshot(output)
if not saved:
raise OSError(f"Could not save screenshot to {output}")
finally:
driver.quit()
The file-oriented alternative
driver.get_screenshot_as_file(filename) is another documented file method for a PNG. It follows the same practical rules: provide a path, use a .png filename, and check the Boolean result.
Recommended Free Tools
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://www.example.com")
if not driver.get_screenshot_as_file("/full/path/page.png"):
raise OSError("Screenshot file could not be written")
finally:
driver.quit()
Choose the representation that matches your next step
| Method | Result | Use it when |
|---|---|---|
save_screenshot(path) |
PNG file plus a Boolean success value | You want an artifact on disk. |
get_screenshot_as_file(path) |
PNG file plus a Boolean success value | You prefer the explicit file-method name. |
get_screenshot_as_png() |
PNG bytes | You will upload, transform, hash, or otherwise process the image in memory. |
get_screenshot_as_base64() |
Base64 text | You need encoded text, such as an image embedded in HTML. |
The file methods are the direct choice for test artifacts and debugging output. Bytes avoid an intermediate file when another Python function or an HTTP client can consume binary data directly. Base64 is text rather than an image file, so decode it before treating it as PNG bytes.
Rank #2
- 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
- 4GB DDR4 System Memory; 128GB Solid State Drive
- 11.6" HD (1366 x 768) Multi-Touch Display
- Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
- Windows 11 Pro
Keep the image in memory as PNG bytes
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://www.example.com")
png_data = driver.get_screenshot_as_png()
# png_data is a bytes object. For example, write it later:
with open("/full/path/deferred.png", "wb") as image_file:
image_file.write(png_data)
Obtain a Base64 string
from selenium import webdriver
with webdriver.Chrome() as driver:
driver.get("https://www.example.com")
encoded = driver.get_screenshot_as_base64()
html = f"<img alt='Selenium capture' src='data:image/png;base64,{encoded}'>"
print(html)
Base64 is useful when the receiving format expects text. If your destination accepts binary uploads, get_screenshot_as_png() avoids that text conversion.
Capture one element instead of the whole browsing context
Locate the element, then call its screenshot() method with a PNG path. This is useful for a heading, card, chart, form, or other component whose bounds matter more than the complete window.
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
try:
driver.get("https://www.example.com")
heading = driver.find_element(By.CSS_SELECTOR, "h1")
heading.screenshot("/full/path/heading.png")
finally:
driver.quit()
The selector determines the capture scope. A CSS selector such as h1 may match more than one element on a real page; use a more specific selector when the screenshot must be deterministic. Locate the element after navigating to the page, and make sure the page state you want is actually present before taking the image.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Make captures reliable in scripts and tests
Use a stable path and verify the write
- Prefer an absolute path for CI jobs, scheduled scripts, and test reports.
- Use a filename ending in
.png, because the documented file methods produce PNG output. - Check the Boolean returned by
save_screenshot()orget_screenshot_as_file(). - Ensure the parent directory exists and that the process has permission to write there.
Close the driver even when capture fails
Put navigation and capture inside try/finally, or use a context manager where your driver setup supports it. This keeps a failed file write or selector lookup from leaving a browser process running.
Capture the intended page state
A screenshot reflects the state rendered at the instant Selenium captures it. Pages that fill content after navigation, change layout during animation, or require an interaction can therefore produce an image different from the one you expected. Arrange the page state first—by waiting for the application condition your test cares about, completing required interactions, and then calling the screenshot method. The screenshot API itself does not decide whether a page is visually ready.
Rank #3
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
Keep scope and representation separate
First decide what to capture: the current browsing context or one located element. Then decide how to handle the result: a PNG file, PNG bytes, or Base64 text. This two-step choice prevents a common mistake such as saving a full-window image when a component-level image was required, or writing a temporary file when an in-memory upload would be simpler.
Full-page expectations and limitations
The normal WebDriver screenshot call should not be presented as a universal full-page solution. The documented material supports a screenshot of the current browsing context and an element screenshot, but it does not establish one cross-browser behavior for the entire scrollable document. If a long page is the requirement, check the current official documentation for the browser-specific full-page capability and test it in the browser versions used by your project.
Until that behavior is verified, describe your output accurately as a viewport or current-window screenshot. If you need a defined region, an element screenshot provides a clearer contract than relying on how a particular browser handles document height.
Troubleshooting common failures
The method returns False
This indicates an I/O error while Selenium tried to write the file. Check that the directory exists, the path is correct, the filename ends in .png, and the running user can write to the location. Switching from a relative path to an absolute path often exposes a working-directory mistake.
No file appears, although the script finishes
Confirm that you checked the return value and that you are looking in the process’s current working directory when using a relative path. Print the absolute destination during debugging, create the parent directory before the call, and use a finally block so cleanup does not obscure the original exception.
Rank #4
- EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
- 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
- RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
- ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
- LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
The image shows the wrong page state
Verify the URL and the active browsing context, then make the application reach the required state before capturing. If content is inserted or rearranged after navigation, capture only after the relevant condition is true. For a component, locate the element after that state is reached rather than reusing an element reference from an earlier page state.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallThe element cannot be captured
Check the CSS selector, confirm that the element exists on the page you loaded, and make the selector specific enough to identify the intended match. A whole-window screenshot can still work when an element selector is wrong; those are separate operations and should be diagnosed separately.
The result is not a whole document
That is expected unless you have confirmed a browser-specific full-page feature. The basic call is documented for the current browsing context, not as a cross-browser guarantee of the entire scrollable page.
The browser remains open after an error
Put driver.quit() in finally. This applies to navigation errors, selector errors, and file-write failures alike.
Performance, storage, and cost considerations
The built-in methods do not require a separate screenshot service or utility. Your local costs are the browser process, image encoding, and whatever disk or memory your workflow uses. Saving to disk is convenient for artifacts but adds file-system work; bytes are more direct for an in-memory pipeline; Base64 is appropriate only when the next interface expects text.
Best Value
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
For a suite that captures many pages, keep output names unique and make the destination part of the test configuration. Avoid silently overwriting a useful failure artifact. If storage is limited, process PNG bytes immediately or remove temporary files after the report has consumed them. If reproducibility matters more than throughput, preserve the URL, selector, and capture path alongside each image so a later failure can be traced to the exact operation.
There is no screenshot-per-call price in Selenium’s local API. Any infrastructure, browser, storage, or CI cost depends on how and where you run the driver, not on a Selenium screenshot quota.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server when you want a URL captured without maintaining a Selenium browser session. Its GET endpoint is https://api.screenshotneo.com/v1/shot. Before capture, it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.
Use the API documentation at https://screenshotneo.com/docs/ for the full parameter list. A one-call PNG, JPEG, or WebP capture looks like this:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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}`);
ScreenshotNeo also supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, 12 device presets or custom viewports, retina scale, PDF output with paper size, margins, landscape, and page ranges, HTML/CSS-to-image, custom JavaScript and CSS, click-before-capture actions, selector hiding, waits for a selector, delay, or network idle, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, configurable-TTL caching, signed public image links, asynchronous jobs with signed 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 to ease migration.
An MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. Every feature is available on every plan: 1,000 shots per month are free with no card; paid plans start at $5 for 3,000 shots. Yearly billing provides two months free. Create a free ScreenshotNeo account to try the 1,000 monthly shots without adding a card.
Frequently Asked Questions
Does Selenium require a separate screenshot plug-in for this basic workflow?
No. The WebDriver screenshot methods are part of Selenium’s built-in API; a separate screenshot utility is not needed for saving the current window or a located element.
What is the safest way to distinguish a capture problem from a file-system problem?
First inspect the Boolean returned by the file method. A false result points to an I/O write failure; a successful write with an unexpected image usually means the page state, browsing context, selector, or capture scope was not the one you intended.
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.

