Windows 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 reinstallCrashes, 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 minuteSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Create the folder in Python before calling Selenium, then give driver.save_screenshot() a PNG path inside it. A unique test name, run ID, or capture ID prevents screenshots from different tests or reruns from colliding.
How to save a Selenium screenshot in a new folder
Selenium saves the current browser window to the filename you supply; it does not create your folder hierarchy. In Python, use pathlib.Path to build the destination and make its parent directories first. The following example creates a new, UTC-timestamped folder for the run and saves a screenshot inside it:
from datetime import datetime, timezone
from pathlib import Path
# Assume `driver` is an active Selenium WebDriver.
run_id = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%S%fZ')
out_dir = Path('screenshots') / run_id
out_dir.mkdir(parents=True, exist_ok=True)
png_path = out_dir / 'homepage.png'
if not driver.save_screenshot(str(png_path)):
raise OSError(f'Could not write screenshot: {png_path}')
The resulting path is similar to screenshots/20260929T150750650227Z/homepage.png. The timestamp is in UTC, with fractional seconds included to reduce the chance of two runs choosing the same name. The example assumes the WebDriver has already opened the page you want to capture.
Selenium’s Python API describes save_screenshot(filename) as saving the current window to a PNG and documents a False return when an I/O error occurs. Passing str(png_path) keeps the argument compatible with bindings and drivers that expect a string filename.
#1 Best Overall
- MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
- SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
- ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
- ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
- HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
Choose what “one folder per screenshot” means
A new directory for every individual image is only one possible layout. Choose the unit that matches how you inspect, archive, and upload test artifacts.
| Layout | Example | Useful when | Trade-off |
|---|---|---|---|
| One folder per test | screenshots/test_login_valid_user/ |
You want all captures from one test together, such as before and after a click. | Reruns can reuse the same folder unless you add a run ID or otherwise handle existing files. |
| One folder per run | screenshots/20260929T150750650227Z/ |
You want to archive or upload all screenshots from a CI run as one artifact. | Test names or descriptive filenames help you find a specific capture within the run. |
| One folder per capture | screenshots/20260929T150750650227Z_homepage/homepage.png |
Downstream tooling expects a separate artifact directory for every image. | This creates more directories and can make a run’s complete set of screenshots less convenient to browse. |
For repeated captures within one test, the simplest approach is usually one test folder with distinct filenames such as before_click.png and after_click.png. If a separate directory is required for each capture, create it immediately before saving, using a unique capture identifier.
Build safe, collision-resistant folder names
Test names make folders readable, but raw names may include path separators, reserved characters, or an impractically long string. Sanitize names before using them as path components, and add a run ID, timestamp, or counter if the same test can execute more than once.
Recommended Free Tools
Rank #2
- Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
- Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
- Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
- Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
- Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
import re
from datetime import datetime, timezone
from pathlib import Path
def safe_name(value: str) -> str:
# Keep letters, digits, underscores, and hyphens; replace other runs.
cleaned = re.sub(r'[^A-Za-z0-9_-]+', '_', value).strip('_')
return cleaned[:80] or 'unnamed_test'
test_name = safe_name('test login / valid user')
run_id = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%S%fZ')
out_dir = Path('screenshots') / f'{test_name}_{run_id}'
out_dir.mkdir(parents=True, exist_ok=True)
png_path = out_dir / 'homepage.png'
if not driver.save_screenshot(str(png_path)):
raise OSError(f'Could not write screenshot: {png_path}')
Sanitizing a name helps prevent characters in a test label from becoming unintended path components. It does not replace choosing an appropriate output root or applying your organization’s rules for handling sensitive test names.
Save several screenshots in one test folder
Create the directory once, then vary the filename for each capture. This keeps the directory layout stable and avoids overwriting an earlier screenshot.
from pathlib import Path
out_dir = Path('screenshots') / 'test_login_valid_user'
out_dir.mkdir(parents=True, exist_ok=True)
for filename in ('before_submit.png', 'after_submit.png'):
png_path = out_dir / filename
if not driver.save_screenshot(str(png_path)):
raise OSError(f'Could not write screenshot: {png_path}')
In real test code, call save_screenshot at the relevant points in the browser flow rather than capturing both images consecutively. If the same test folder is reused on reruns, decide whether to overwrite, clean the old folder, or include a unique run ID.
Rank #3
- Plug-and-play expandability
- SuperSpeed USB 3.2 Gen 1 (5Gbps)
Use a per-test directory with pytest
A fixture can provide each pytest test with its own directory. This example uses the test name as a readable component and a UTC timestamp to distinguish repeated executions:
Free tools Windows power users keep installed
One-click scans. No signup required.
from datetime import datetime, timezone
from pathlib import Path
import re
import pytest
@pytest.fixture
def screenshot_dir(request):
test_name = re.sub(r'[^A-Za-z0-9_-]+', '_', request.node.name).strip('_')
test_name = test_name[:80] or 'unnamed_test'
run_id = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%S%fZ')
out_dir = Path('screenshots') / f'{test_name}_{run_id}'
out_dir.mkdir(parents=True, exist_ok=True)
return out_dir
def test_homepage(driver, screenshot_dir):
# Navigate to the page before capturing it.
driver.get('https://example.com')
png_path = screenshot_dir / 'homepage.png'
if not driver.save_screenshot(str(png_path)):
raise OSError(f'Could not write screenshot: {png_path}')
This example expects a pytest fixture named driver to be supplied by your project; it does not define how that browser is created or managed. The Selenium API does not impose a particular testing framework or folder layout, so the caller chooses both.
Use a per-test directory with unittest or another runner
For another test framework, apply the same pattern in a helper or test setup method: derive a readable directory name from the current test, add a run identifier when needed, create the directory, and pass the resulting PNG path to Selenium. Keep this path logic separate from browser actions so it can be reused across tests and runners.
Rank #4
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
For a one-off capture, the minimal equivalent is:
from pathlib import Path
out_dir = Path('screenshots') / 'test_login_valid_user'
out_dir.mkdir(parents=True, exist_ok=True)
png_path = out_dir / 'login.png'
if not driver.save_screenshot(str(png_path)):
raise OSError(f'Could not write screenshot: {png_path}')
Where the files go, and how to handle CI artifacts
A relative path such as Path('screenshots') is resolved from the Python process’s current working directory, which may differ between a local run and a CI job. If the output needs to live in a particular workspace or artifact directory, use an explicit base path from your test configuration or environment, then append the generated test or run folder to it.
- Make artifacts easy to locate: include a readable test name in the directory or filename, while keeping a unique run component where reruns might otherwise collide.
- Keep uploads predictable: if your CI system collects one directory per job, a run-level folder can group the complete set of captures.
- Check what is uploaded: directory creation and screenshot saving write files locally; your CI system still needs to collect or upload the chosen output path.
- Keep paths portable: build paths with
Pathcomponents rather than manually joining strings with a slash, so Python can use the platform’s path conventions.
The save call should receive a filename including the .png suffix. Selenium’s remote WebDriver documentation also describes get_screenshot_as_file(filename) as writing a PNG file and returning False on an I/O error.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshoot missing or failed screenshots
- The parent directory does not exist: create it before saving with
out_dir.mkdir(parents=True, exist_ok=True). Without that step, the save operation cannot create the missing folder hierarchy for you. save_screenshot()returnsFalse: treat this as a failed write, not a successful capture. Check the destination path and whether the process can write to that location; raise an error or log the full path so the failure is actionable.- The image is saved somewhere unexpected: inspect the process’s current working directory when using a relative output root, or configure an explicit base directory.
- A later capture replaces an earlier one: use a different filename for each image, or add a unique test, run, timestamp, or capture identifier to the directory.
- A test name creates a surprising path: sanitize separators and other unsuitable characters, limit the name length, and append a unique component if the sanitized names could match.
- The directory exists but the screenshot is absent: confirm that the browser action reached the save call and check the boolean result. Creating a folder alone does not guarantee the image was written.
- The file is not available as a CI artifact: confirm that the job collects the directory where the process actually wrote the screenshot. Saving locally and uploading an artifact are separate steps.
Or skip the browser setup
If you need an image of a public webpage rather than a screenshot taken from an already-running Selenium session, ScreenshotNeo can return an image from one GET request. It is a website screenshot API and MCP server from Yorker Media; it does not run your Selenium test or capture its browser state.
Best Value
- NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
- IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
- POCKET-SIZED – fits easily in pockets and small bags.
- SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
- 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.
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. Its cookie/consent-banner handling accepts banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and 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 1,000 free screenshots a month, with no card required.
Practical limits and reliability notes
The filesystem is part of this workflow: Python creates the directories, and Selenium writes to the supplied filename. A unique folder helps prevent name collisions, but does not by itself guarantee that the browser reached the intended page or that the process can write to the chosen location. Check the returned boolean, make the output root explicit when the working directory varies, and ensure your test runner archives the directory if you need the files outside the job workspace.
For large test suites, keep naming deterministic enough that a failed test’s files are easy to find, but unique enough that concurrent jobs or reruns do not silently reuse the same folder. A timestamp is a convenient run identifier; a CI job identifier or other unique value can serve the same purpose when available.
Frequently Asked Questions
Does Selenium create the screenshot folder automatically?
No. Create the destination directory in your code before calling Selenium’s screenshot method.
Can I save a Selenium screenshot as a JPEG?
The Selenium methods discussed here save screenshots as PNG files; use a PNG filename such as capture.png.
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.
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 errors

