Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesIn Python, call driver.save_screenshot("screenshot.png") to save a PNG of the current browser window. Check its Boolean return value: True means the file was saved; False indicates an I/O error. Use a writable path ending in .png.
Save the current browser window as a PNG in Python
Selenium’s Python WebDriver API documents save_screenshot(filename) as saving a screenshot of the current window to a PNG image file. It also documents get_screenshot_as_file(filename) for the same purpose. The filename should end in .png, and both methods return False on an I/O error and True otherwise. See the Selenium Python WebDriver API reference.
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.png")
finally:
driver.quit()
Remove the extra leading space before driver = webdriver.Chrome() if copying this snippet: at top level, Python requires it to align with the try statement. Here is the correctly aligned version:
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.png")
finally:
driver.quit()
The example uses the current Selenium Python API. It assumes Selenium and a working Chrome/WebDriver setup are already available in the environment where the script runs. driver.get() navigates to the page before the capture; the screenshot call captures the current browser window at that point. The finally block closes the browser even if navigation or file saving raises an exception.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- 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
Use a deliberate output path
A relative filename such as screenshot.png is resolved relative to the process’s working directory, which may not be the directory containing the script. The Selenium API recommends a full path where appropriate. Choose a location that the test process can write to, for example /tmp/screenshot.png on a suitable Unix-like system or an absolute Windows path such as C:\temp\screenshot.png. Make sure the destination directory exists; the screenshot method does not create missing parent directories for you.
Why the extension matters
Selenium’s screenshot operation produces PNG data. Naming the file screenshot.png gives the file an extension consistent with that content. Changing the extension does not convert the screenshot into a different image format. The Python implementation warns when the filename does not end in .png, writes the screenshot bytes in binary mode, and returns False for an OSError.
Choose the right screenshot output and target
The right method depends on whether you need a file, image data for another operation, the whole current browser window, or a single element. These Python methods and targets are documented in Selenium’s WebDriver API and WebElement API.
| Need | Python API | Result |
|---|---|---|
| Save the current window directly | driver.save_screenshot("screenshot.png") |
PNG file; check the Boolean return. |
| Save the current window through the alternate file method | driver.get_screenshot_as_file("screenshot.png") |
PNG file; check the Boolean return. |
| Pass image bytes to code or a storage client | driver.get_screenshot_as_png() |
PNG bytes, without first writing a local file. |
| Obtain a base64 representation | driver.get_screenshot_as_base64() |
Base64-encoded screenshot string; Selenium notes this can be useful for embedding in HTML. |
| Capture one page element | element.screenshot("element.png") or element.screenshot_as_png |
Element-targeted PNG file or bytes, rather than a driver-level window capture. |
Write PNG bytes directly when another API needs them
If the next step uploads, transforms, or stores the image through a library that accepts bytes, avoid creating a temporary file just to read it back:
Recommended Free Tools
Rank #2
- 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
png_bytes = driver.get_screenshot_as_png()
# Pass png_bytes to the API or library that accepts image bytes.
The bytes are PNG image data. The receiving code is responsible for handling them; the screenshot call itself does not choose a storage destination.
Use base64 only when the consumer expects it
get_screenshot_as_base64() returns encoded text rather than raw bytes. It is useful when a downstream consumer expects a base64 value, including the HTML-embedding use noted in Selenium’s API documentation. If a file is your actual goal, save_screenshot() is more direct.
Capture an element instead of the window
Find the target element first, then use the WebElement screenshot API. For example:
element = driver.find_element("css selector", ".product-card")
saved = element.screenshot("product-card.png")
if not saved:
raise OSError("Could not save product-card.png")
This changes the target from the driver’s current window to the selected element. Selenium’s Python WebElement reference also documents element screenshot data as file, bytes, and base64 forms. Use an element capture when the output should be limited to one DOM element, not as a substitute for a full-page screenshot.
Rank #3
- 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.
What the screenshot includes—and what it does not promise
The driver-level screenshot is documented as a capture of the current window or browsing context. The WebDriver documentation describes the screenshot endpoint response as Base64 encoded; Selenium’s language bindings then expose output forms appropriate to each binding. A window screenshot should not be assumed to capture an entire long page beyond the visible viewport in every browser and driver combination.
Element screenshots are a separate target. Implementation behavior can also vary by driver: Selenium’s Java API explains that W3C-conformant drivers and elements follow the W3C WebDriver specification, while non-conformant implementations use best effort, so capture scope can differ. Ruby’s API marks its screenshot module private and says full-page capture is available only where supported. These qualifications are reasons not to treat full-page capture as a universal promise across Selenium bindings and drivers.
Save screenshots in other Selenium language bindings
The method names and file-handling details differ across bindings. Selenium’s WebDriver windows and tabs documentation includes screenshot examples for multiple languages; use the API for the binding used by your test project.
Java
Java uses TakesScreenshot and an output type. Selenium’s official example gets a file and copies it to the destination path:
Rank #4
- 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
File source = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
File destination = new File("screenshot.png");
FileHandler.copy(source, destination);
The relevant APIs are documented in Selenium’s Java TakesScreenshot reference and the linked WebDriver examples. The file copy is distinct from the Python convenience method; do not assume Python’s Boolean return contract or method names apply to Java.
C#
The Selenium C# example casts the driver to ITakesScreenshot, calls GetScreenshot(), then saves with ScreenshotImageFormat.Png. Follow the official language example for its exact namespaces and setup rather than substituting Python APIs.
Ruby
The Ruby example calls driver.save_screenshot('./image.png'). The Ruby API reference says the path should end in .png and describes its screenshot module as private; it also says full-page capture is available only if supported. Treat the documented call as binding-specific and avoid relying on that private module as a portable full-page interface.
JavaScript
The Selenium example obtains a base64 screenshot string using driver.takeScreenshot(), then writes it using Node’s fs.writeFileSync(..., 'base64'). This differs from Python’s direct file-save method. Consult the WebDriver examples for the full setup and imports for the version in use.
Best Value
- 【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.
Troubleshoot a missing or unusable PNG
- The file is not where expected: A relative path is based on the process working directory, not necessarily the script’s folder. Print or inspect the working directory, or supply a full destination path.
- The destination cannot be written: Ensure the running test user has permission to write there and that the parent directory exists. In Python, a file-save I/O failure is reported as
False; raise or log an error when the return is false. - The file has the wrong extension: Use a path ending with
.png. Selenium warns when the Python filename does not end in that extension. The screenshot operation supplies PNG data; a different suffix does not convert it. - A page image or widget is missing: Capture only after the page has reached the state your test needs. The screenshot method captures the current window; it does not by itself guarantee that asynchronous page content has loaded.
- You captured too much or too little: Decide whether the target is the driver’s current window or one element. Use
element.screenshot(...)for a specific element. Do not assume a driver screenshot is a portable full-page capture. - You need to send the image elsewhere: Use
get_screenshot_as_png()for bytes orget_screenshot_as_base64()for base64 instead of saving and rereading a file. - The browser remains open after an error: Put browser cleanup in a
finallyblock and calldriver.quit(), so exceptions during navigation or capture do not skip cleanup.
Or skip the browser setup
If your task is to capture a website from an application rather than test it through Selenium, ScreenshotNeo provides a screenshot API and MCP server. Its one-call GET endpoint returns a screenshot or PDF, and the API accepts the familiar screenshot parameter names used by other screenshot APIs to make switching easier. For a regular-page PNG, request PNG output as configured for your use case and save the returned response body:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.png
See the ScreenshotNeo API documentation for the output options and request parameters. Cookie banners are accepted and more than 60 known consent platforms, newsletter popups, and chat widgets can be removed before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan.
FAQ
Does saving the screenshot as PNG convert it from another format?
No. Selenium’s documented screenshot operation produces PNG data; the .png suffix names the file consistently with that data.
Can I capture only one element with Selenium?
Yes. In Python, use the selected WebElement’s screenshot method, such as element.screenshot("element.png"), rather than the driver-level window method.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows 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 reinstallIs a Selenium driver screenshot always a full-page image?
No. The documented driver target is the current window or browsing context, and full-page behavior is not a universal guarantee across bindings and drivers.
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.




