What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Make the destination directory, build a filename that ends in .png, and pass its path to driver.save_screenshot(). Selenium writes a PNG of the current browser window; it does not create missing parent folders for you. Check the method’s Boolean result so a failed write does not pass unnoticed.
Save a Selenium screenshot to a folder
This example creates a screenshots folder under the process’s current working directory, opens a page in Chrome, saves a window screenshot, checks whether it was written, and closes the browser even if an error occurs.
from pathlib import Path
from selenium import webdriver
screenshot_dir = Path("screenshots")
screenshot_dir.mkdir(parents=True, exist_ok=True)
output = screenshot_dir / "example.png"
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
saved = driver.save_screenshot(str(output))
if not saved:
raise OSError(f"Selenium could not save {output.resolve()}")
print(f"Screenshot saved to {output.resolve()}")
finally:
driver.quit()
The essential call is driver.save_screenshot(str(output)). The path includes both the directory and the filename. Selenium’s Python API describes this as saving a PNG screenshot of the current window, recommends using a full path, and says the filename should end in .png. Convert the Path object to a string for broad compatibility with Selenium versions.
The folder is created before the screenshot call. parents=True also creates any missing directories above it; exist_ok=True lets the script run when the folder already exists. Selenium’s file-saving method writes the image but does not create the parent directory. If writing fails because of an I/O error, the method returns False, which is why the example checks the result.
#1 Best Overall
Choose a path that lands where you expect
Relative paths
Path("screenshots") is relative. Python resolves it from the process’s current working directory, which may not be the folder containing your script. A test runner, IDE, scheduled task, or CI job can start the process from a different directory than your terminal does. Print the resolved path when diagnosing where an artifact went:
print(output.resolve())
To make the location explicit relative to the working directory, construct an absolute path from Path.cwd() and create its parent directory:
from pathlib import Path
output = Path.cwd() / "artifacts" / "screenshots" / "example.png"
output.parent.mkdir(parents=True, exist_ok=True)
saved = driver.save_screenshot(str(output))
if not saved:
raise OSError(f"Screenshot write failed: {output.resolve()}")
This still uses the process working directory as its anchor, but makes the resolved destination visible and predictable for that run. If your project or CI system provides a configured artifact directory, use that location instead of assuming the working directory is the project root.
One folder, several screenshots
For a script that only needs the latest result, reuse a deterministic name such as home.png; saving again replaces the file. If you need to keep a history, add a test-case identifier or a UTC timestamp to the filename. Create the folder once, then reuse it:
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 →Clear out junk files and repair common Windows errorsFree Scan →Rank #2
from datetime import datetime, timezone
from pathlib import Path
folder = Path("screenshots")
folder.mkdir(parents=True, exist_ok=True)
stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
output = folder / f"checkout-{stamp}.png"
saved = driver.save_screenshot(str(output))
if not saved:
raise OSError(f"Screenshot write failed: {output.resolve()}")
A timestamp is useful when each run’s image matters, but deterministic names are easier when a test should replace its previous artifact. Including a page, test, or step name can make a directory of retained screenshots easier to inspect.
Capture one element instead of the browser window
When the artifact should contain a single rendered element, find the WebElement and call its own screenshot() method. This saves the element image to the supplied path rather than using the driver-level window screenshot method:
from pathlib import Path
folder = Path("screenshots")
folder.mkdir(parents=True, exist_ok=True)
button = driver.find_element("css selector", "button.submit")
element_path = folder / "submit-button.png"
if not button.screenshot(str(element_path)):
raise OSError(f"Element screenshot write failed: {element_path.resolve()}")
Use a selector that identifies the intended element, and locate it only after the page has reached the state where it exists and is rendered. If the lookup fails, the problem occurs before the screenshot is written; if the element screenshot returns false, treat that as a failed write. A driver-level capture and an element-level capture answer different needs: the former is the current browser window, while the latter is the selected WebElement.
Window screenshots are not automatically full-page screenshots
driver.save_screenshot() captures the current window. Do not assume it includes all content below the fold in a long, scrollable document. The Python bindings document a separate full-document screenshot capability for Firefox, so full-page capture is a distinct, browser-dependent requirement rather than an automatic effect of the ordinary window method.
Rank #3
If you need a complete page, verify that the specific browser and capture method you choose support full-document output. Also consider whether content appears only after scrolling, since the image must include the content you intend to capture. For a simple viewport artifact, use save_screenshot(); for one component, use the element method; for the full document, select a separate full-page approach and account for browser support.
Other screenshot output forms
The WebDriver API also exposes screenshot data as PNG bytes and as base64, in addition to writing a PNG file. Those forms are useful when another part of your program will handle the data rather than a local file path. The folder-saving method is the direct choice when the deliverable should be an image file in a directory. Keep output expectations explicit: this method’s file output is PNG, and a .png suffix makes that clear to downstream tools and people inspecting artifacts.
Or skip the browser setup
If you need a screenshot from a URL without managing a Selenium browser session, ScreenshotNeo provides a screenshot API. The cURL request below saves the returned image to shot.webp; replace the example URL with the page you need and use your API key.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and whether the request was billed. ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. See ScreenshotNeo for the service and plans.
Rank #4
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Troubleshooting screenshot files
No file appears
- Resolve and print the path with
Path(output).resolve()oroutput.resolve()so you can see the destination the process is using. - Confirm that the parent folder exists before calling Selenium. Use
output.parent.mkdir(parents=True, exist_ok=True)when necessary. - Check the Boolean returned by
save_screenshot(). A false result signals that an I/O error prevented saving; raise an error or otherwise report the failure instead of treating the capture as successful.
The screenshot is in the wrong directory
Check the process working directory. A relative path is interpreted from there, not necessarily from the script’s location. Use Path.cwd() to anchor the output to the current directory, or supply the absolute path of the artifact directory your environment expects.
A previous image disappeared
If repeated runs use the same filename, a later screenshot replaces the earlier file. Choose a stable name when replacement is intended. Use a timestamp or a test-specific name when you need to retain multiple runs.
The element screenshot cannot be taken
First confirm that the locator returns the intended WebElement and that the element is present and rendered at the time of capture. Then call element.screenshot() with a destination ending in .png. A driver screenshot captures the window; it is not a substitute for selecting the element when only that element is required.
Best Value
The result cuts off content below the fold
That is consistent with a current-window screenshot: the basic method does not promise the entire scrollable document. Use a full-page method supported by your browser and verify its behavior for your target page rather than assuming the window method scrolls and stitches the document.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Practical reliability and cost considerations
A local Selenium screenshot writes an artifact to the machine or environment running the browser. In CI, make sure the chosen directory is retained or uploaded by the job if you need to retrieve the image after the run; writing a file alone does not make it available outside that environment. Prefer descriptive paths so artifacts can be associated with a test, and check the return value so a write failure becomes a visible test or script failure.
There is no numeric performance figure established for this workflow. The screenshot is taken after the browser has navigated to the page, so the point at which your code calls the method determines what is visible. If the page has not reached the state you intend to inspect, the saved image may not represent the desired result. Treat page readiness and screenshot writing as separate concerns: first ensure the relevant content is present, then capture and validate the output path.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsThe local method does not introduce an API price per capture, but it does require a working browser session and a writable destination in the environment where Python runs. A hosted screenshot API instead moves browser capture into a service request; compare that convenience with the need to configure access keys and ensure the requested page is appropriate to send to that service.
Frequently Asked Questions
Can I save the screenshot as JPEG or WebP with `driver.save_screenshot()`?
The documented Selenium file method writes PNG output and expects a `.png` filename. If you need another image format, convert the PNG separately or use a capture method that explicitly supports the format you need.
Does Selenium create the screenshots folder automatically?
No. Create the parent directory in Python before calling the file-saving method; `Path.mkdir(parents=True, exist_ok=True)` is a convenient way to do it.
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.
Recommended Free Tools

