The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →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 Selenium’s Python bindings, the screenshot filename is the destination. Create the directory yourself, build a resolved path that ends in .png, call driver.save_screenshot() (or get_screenshot_as_file()), and check the Boolean result. Selenium does not select a hidden screenshots folder for you.
Save a screenshot to an explicit folder
This complete example places the image in an artifacts/screenshots directory beside the Python file. mkdir() creates every missing parent directory, and the resolved path remains stable when the test is launched from an IDE, a shell, or a CI runner.
from pathlib import Path
from selenium import webdriver
screenshot_dir = Path(__file__).resolve().parent / "artifacts" / "screenshots"
screenshot_dir.mkdir(parents=True, exist_ok=True)
output_file = screenshot_dir / "login-page.png"
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
ok = driver.save_screenshot(str(output_file))
if not ok:
raise OSError(f"Selenium could not write screenshot: {output_file}")
finally:
driver.quit()
The filename argument is the complete destination. Selenium’s Python API saves the current window as a PNG, recommends full paths, and returns False when an I/O error prevents the write. Raising an error when that happens keeps a test run from appearing successful while its artifact is missing.
Why screenshots appear in the “wrong” directory
Relative paths use the process working directory
A path such as screenshots/home.png is interpreted relative to the process’s current working directory. That directory can differ when you run a file from an IDE, invoke a test command from the repository root, or execute it in CI. It is not automatically relative to the folder containing the test file.
#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
Resolve a project or artifact root deliberately
Path(__file__).resolve().parent anchors the example to the source file. If your build system supplies an artifact directory, use that directory as the base instead and still create it before the call:
from pathlib import Path
import os
base = Path(os.environ.get("SCREENSHOT_DIR", Path(__file__).resolve().parent / "artifacts"))
output_file = base / "screenshots" / "checkout.png"
output_file.parent.mkdir(parents=True, exist_ok=True)
In an interactive session where __file__ is unavailable, choose an explicit absolute base such as Path.cwd() / "artifacts", then log the resulting path so the location is visible in the run output.
Use the equivalent file method when it reads more clearly
get_screenshot_as_file() is the documented equivalent of save_screenshot() for writing a PNG file. The path and return-value rules are the same:
output_file.parent.mkdir(parents=True, exist_ok=True)
if not driver.get_screenshot_as_file(str(output_file)):
raise OSError(f"Screenshot write failed: {output_file}")
Keep the .png suffix. Selenium’s API specifies PNG output and warns when the supplied filename does not end in .png. A directory path is not a filename; provide the final name as well as its parent folder.
Build a reusable screenshot helper
Centralizing path creation prevents individual tests from silently using different working directories or forgetting to create a parent folder.
from pathlib import Path
from selenium.webdriver.remote.webdriver import WebDriver
def save_artifact(driver: WebDriver, root: Path, name: str) -> Path:
"""Save the current WebDriver window and return its absolute path."""
filename = name if name.endswith(".png") else f"{name}.png"
destination = (root / filename).resolve()
destination.parent.mkdir(parents=True, exist_ok=True)
if not driver.save_screenshot(str(destination)):
raise OSError(f"Selenium could not write screenshot: {destination}")
return destination
# Example:
# path = save_artifact(driver, Path("artifacts/screenshots"), "login-page")
# print(f"Screenshot written to {path}")
The helper normalizes a missing extension, creates parents, converts the path to an absolute location, and turns Selenium’s Boolean failure signal into an exception that your test runner can report.
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
Name files so evidence is retained
- Include the scenario: names such as
login-invalid-password.pngare easier to identify thanimage.png. - Include a unique value when retaining every failure: add a test identifier, timestamp, or run ID. Reusing a path simply writes that path again, so the previous image is replaced.
- Keep the extension lowercase and explicit: the Selenium API expects a PNG filename.
- Print the resolved destination: this makes it possible to find artifacts when a runner copies them to a separate report directory.
Understand what Selenium reports when a write fails
The method’s True/False result concerns the file operation. The Python implementation obtains PNG bytes, opens the exact filename in binary-write mode, writes those bytes, and returns True. If opening or writing raises OSError, the method returns False.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Falsewith a missing file: inspect the resolved path, permissions, and parent-directory creation. Do not ignore the result.- An exception before a Boolean result: a WebDriver command or browser session may have failed before the file write. Handle that separately from filesystem errors.
- A file in an unexpected location: print
Path(output_file).resolve()and check whether the original path was relative.
Use PNG bytes or base64 when your code owns storage
You do not have to let Selenium write directly to disk. get_screenshot_as_png() returns PNG bytes, while get_screenshot_as_base64() returns a base64 string suitable for embedding in HTML.
# Write the bytes yourself
png_bytes = driver.get_screenshot_as_png()
output_file.parent.mkdir(parents=True, exist_ok=True)
output_file.write_bytes(png_bytes)
# Embed in an HTML data URL
import base64
encoded = driver.get_screenshot_as_base64()
data_url = "data:image/png;base64," + encoded
This approach is useful when an artifact service, database, or report generator—not Selenium—controls persistence. You still choose the final destination and should handle storage errors from the code that writes the bytes.
Path patterns that work across local runs and CI
Repository-relative artifacts
Anchor the path to a known project directory rather than assuming the command is launched from one particular folder:
project_root = Path(__file__).resolve().parents[1]
artifact_dir = project_root / "test-artifacts" / "screenshots"
artifact_dir.mkdir(parents=True, exist_ok=True)
file_path = artifact_dir / "home.png"
Adjust the number of parents levels to match your layout. The important part is resolving the base once and deriving every screenshot path from it.
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 glitchesRunner-provided artifact directories
Many CI systems expose an environment variable for files that should be collected after a job. Read that variable when present, create a screenshots subdirectory, and fall back to a local artifact folder when it is absent. Avoid writing to a temporary working directory unless the runner is configured to preserve it.
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.
Parallel tests
Give each test or worker a distinct filename. A shared directory is fine, but a shared filename is not: ordinary binary writes target the same path and can overwrite an earlier capture.
Troubleshoot the common path problems
“The folder does not exist”
Cause: save_screenshot() writes a file but does not create missing parents. Fix: call destination.parent.mkdir(parents=True, exist_ok=True) before saving and check for False.
“The image is beside my project, not beside my test”
Cause: the supplied path was relative, so it was resolved against the process working directory. Fix: use Path(__file__).resolve(), a configured project root, or an explicit CI artifact variable.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →“The method returned False”
Cause: Selenium encountered an operating-system error while opening or writing the destination. Fix: log the absolute path, verify that its parent exists, check write permissions and available storage, and raise an error instead of continuing.
“Selenium warns about the filename”
Cause: the name does not end in .png, or a directory was supplied where a filename was expected. Fix: append a PNG filename, for example artifacts/screenshots/cart.png.
“Every failure screenshot has the same content”
Cause: each test reused one destination and the latest write replaced the previous image. Fix: include a scenario name and unique run value in each filename.
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
“The screenshot is not the page state I expected”
Cause: the call captures the current WebDriver window at the instant it runs. Fix: place the call after the navigation and interactions whose result you want to document, while the driver session is still active.
Free tools Windows power users keep installed
One-click scans. No signup required.
Performance and reliability considerations
Screenshot capture is synchronous in this API: the call obtains an image from the active browser and writes it before returning. Keep the destination on storage that the process can write reliably, and do not quit the driver until the call and any error handling are complete. If you need several artifacts, generate deterministic names first so a later failure cannot obscure an earlier one.
The PNG byte and base64 methods avoid Selenium’s direct file write, but they move storage responsibility to your application. That gives you control over an artifact service or HTML report, at the cost of handling encoding, persistence, and error reporting yourself. Whichever representation you use, record the final path or identifier alongside the test result.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
When the target is a public URL rather than a browser interaction that your test must perform, ScreenshotNeo provides a hosted screenshot API. It is the first alternative to try because it removes consent banners, newsletter popups, and chat widgets before capture; only clean shots are billed; failed loads and other non-page results are not billed; and its paid entry plan is $5 for 3,000 shots.
One GET request returns a PNG, JPEG, WebP, or PDF. The API accepts a URL and access key; the complete options and response headers are documented at ScreenshotNeo’s API documentation.
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}`);
ScreenshotNeo’s response identifies the result with X-Page-Verdict and X-Billed headers. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. An MCP server supplies take_screenshot, get_page_info, and capture_pdf tools to Claude, Cursor, and other MCP clients.
For pages that need more than a default viewport, the service offers full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, selector or network-idle waits, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, caller-selected cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs. Every feature is included on every plan.
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.
| 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. If you want to try the hosted route, create a free ScreenshotNeo account: 1,000 screenshots a month are included with no card required.
FAQ
Does a False result prove that the browser failed?
No. The documented Boolean specifically reports an operating-system error while opening or writing the file. A browser or WebDriver problem can occur earlier and should be handled as its own exception path.
Recommended Free Tools
Can I keep the screenshot without writing it immediately?
Yes. Request PNG bytes with get_screenshot_as_png() or a base64 representation with get_screenshot_as_base64(), then let your report or storage layer decide when and where to persist it.
Is ScreenshotNeo a replacement for an interaction test?
No. Selenium remains appropriate when the test must drive clicks, typing, authentication, or other browser actions. ScreenshotNeo is a separate URL-capture service for obtaining a clean image or PDF without launching that browser workflow.
Frequently Asked Questions
Does a False result prove that the browser failed?
No. The documented Boolean specifically reports an operating-system error while opening or writing the file. A browser or WebDriver problem can occur earlier and should be handled as its own exception path.
Can I keep the screenshot without writing it immediately?
Yes. Request PNG bytes with get_screenshot_as_png() or a base64 representation with get_screenshot_as_base64(), then let your report or storage layer decide when and where to persist it.
Is ScreenshotNeo a replacement for an interaction test?
No. Selenium remains appropriate when the test must drive clicks, typing, authentication, or other browser actions. ScreenshotNeo is a separate URL-capture service for obtaining a clean image or PDF without launching that browser workflow.
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.

