Recommended Free Tools
To screenshot the application Selenium is currently controlling, call the screenshot method on the active WebDriver session. In Python, driver.save_screenshot("screenshot.png") saves a PNG of the current browsing context. If the application is open in another tab or window, switch to its window handle before capturing.
What “current application” means in Selenium
Selenium takes a screenshot of the active WebDriver browsing context: the browser window or tab selected by the current session. It does not choose an application by its name, nor does it automatically switch to the tab you most recently viewed outside WebDriver. Selenium’s documentation describes the target as the “current browsing context.” Selenium: Working with windows and tabs.
For a normal application screenshot, first make sure WebDriver is attached to the intended session, the page has reached the state you want, and the correct tab or window is selected. Then use your language binding’s driver screenshot method. If you need only one HTML element, use that element’s screenshot method instead.
Take a screenshot in Python
The concise Python method is save_screenshot(). It writes a PNG to the path you provide and returns True when the file is saved or False if an I/O error occurs. Selenium’s Python WebDriver API documentation identifies version 4.49.0. Python WebDriver API.
#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
from selenium import webdriver
# Assumes the browser and application are already open in this session.
driver = webdriver.Chrome()
driver.get("https://example.com")
saved = driver.save_screenshot("screenshot.png")
if not saved:
raise OSError("Selenium could not save screenshot.png")
driver.quit()
Replace the example URL with your application. If a test already owns a configured driver, use that driver rather than creating a second session. The screenshot must be taken before quitting the session. For a relative filename, Selenium writes relative to the process’s working directory; use an absolute path if you need a predictable destination.
Save to an explicit path
from pathlib import Path
output = Path("artifacts") / "application.png"
output.parent.mkdir(parents=True, exist_ok=True)
if not driver.save_screenshot(str(output.resolve())):
raise OSError(f"Screenshot could not be saved to {output}")
Creating the parent directory avoids a common file-save failure. Selenium’s method accepts a filename; it does not create missing directories for you.
Use the correct tab or window first
WebDriver treats tabs and windows through window handles. If your workflow opens a new tab or popup and the screenshot shows the wrong page, switch to the intended handle before calling save_screenshot().
# Example: remember the current window, then open a new tab in the test.
original = driver.current_window_handle
before = set(driver.window_handles)
driver.execute_script("window.open('https://example.com/app', '_blank')")
# Wait for the new handle in production code rather than relying on a fixed delay.
from selenium.webdriver.support.ui import WebDriverWait
WebDriverWait(driver, 10).until(
lambda d: len(set(d.window_handles) - before) == 1
)
new_handle = (set(driver.window_handles) - before).pop()
driver.switch_to.window(new_handle)
if not driver.save_screenshot("application.png"):
raise OSError("Screenshot save failed")
Use the handle for the application you want, not simply the first item in window_handles. Window ordering is not a reliable way to identify the target. After capture, switch back to original if the rest of your test needs the earlier context.
Choose the output you need
Python offers three useful forms: save directly to a file, retrieve PNG bytes, or retrieve a base64-encoded PNG. Choose based on what the next step consumes.
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
| Method | Result | Use it when |
|---|---|---|
driver.save_screenshot(path) |
PNG file; Boolean success result | You need a file artifact for a test report or manual inspection. |
driver.get_screenshot_as_png() |
PNG image bytes | You want to pass image data to another Python library or write it yourself. |
driver.get_screenshot_as_base64() |
Base64-encoded PNG string | The receiving system expects base64 data, such as an embedded image field. |
These methods are documented in the Selenium Python WebDriver API.
png_bytes = driver.get_screenshot_as_png()
with open("application.png", "wb") as image_file:
image_file.write(png_bytes)
png_base64 = driver.get_screenshot_as_base64()
PNG bytes are binary, so write them with "wb", not text mode. Base64 is an encoded representation, not a PNG file’s raw bytes; decode it before writing a conventional image file.
Capture one element instead of the application view
If the requirement is a chart, dialog, card, or other single element, locate that element and call its screenshot method. This is a different target from the current window and is useful when surrounding interface content should not appear in the image.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
chart = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "#sales-chart"))
)
if not chart.screenshot("sales-chart.png"):
raise OSError("Could not save element screenshot")
The selector is application-specific. Wait for visibility when the element is rendered asynchronously; locating an element alone does not guarantee it is ready to capture. Selenium’s official window and tab documentation includes an element screenshot example, and the Java API also documents screenshot support for elements: Working with windows and tabs and Java TakesScreenshot API.
Capture extent: viewport, window, or full page
Do not assume that a driver screenshot always contains the entire vertically scrolling page. Screenshot scope can depend on the browser, driver, binding, and implementation. The Selenium JavaScript API describes a best-effort order: entire page, current window, visible portion of the current frame, then the entire display containing the browser. The Java API describes comparable best-effort behavior for non-W3C-conformant implementations and notes that W3C-conformant drivers and elements follow the WebDriver specification. See the JavaScript WebDriver API and Java TakesScreenshot API.
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.
For a dependable workflow, decide whether the requirement is a current-window screenshot or a full-page image. If full-page coverage matters, verify the behavior with your configured browser and driver instead of treating the method name as a guarantee. An element screenshot targets one element; it is not a substitute for a full-page capture.
Java and JavaScript examples
Java
In Java, use the TakesScreenshot interface and request a file output. The returned file is a temporary screenshot file, so copy it to the path your test artifacts use.
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 →import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
WebDriver driver = /* your configured driver */;
File temporaryScreenshot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
Path destination = Path.of("artifacts", "application.png");
Files.createDirectories(destination.getParent());
Files.copy(temporaryScreenshot.toPath(), destination,
StandardCopyOption.REPLACE_EXISTING);
The driver must support the screenshot interface, and the destination directory must be writable. The Java API documents output types and implementation caveats in TakesScreenshot.
JavaScript
In Selenium’s JavaScript binding, takeScreenshot() resolves to a base64-encoded PNG string. Decode it to bytes to save a PNG file.
const fs = require('node:fs/promises');
const { Builder } = require('selenium-webdriver');
(async () => {
const driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('https://example.com');
const base64 = await driver.takeScreenshot();
await fs.writeFile('application.png', Buffer.from(base64, 'base64'));
} finally {
await driver.quit();
}
})();
The documented return is base64 image data; the file conversion above is done by Node.js. Consult the Selenium JavaScript WebDriver API for screenshot behavior and extent caveats.
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
Make screenshots useful in automated tests
- Capture after the intended state is ready. Wait for a visible element, a completed navigation, or the condition your test actually needs; arbitrary short sleeps can produce inconsistent artifacts.
- Keep the screenshot near the failure. In a test framework, capture on failure before the teardown closes the browser session.
- Use a deterministic filename and directory. Include a test name or run identifier if multiple captures might overwrite one another.
- Choose file versus in-memory data deliberately. Save a PNG for an artifact; use bytes or base64 when an API or reporting integration needs data directly.
- Record the browser and driver setup for full-page requirements. The screenshot extent is implementation-sensitive, so repeatability depends on verifying the actual configured combination.
Troubleshooting Selenium screenshots
The screenshot shows the wrong tab
The session was still focused on another browsing context. Inspect driver.current_window_handle and driver.window_handles, then call driver.switch_to.window(target_handle) before capturing. Do not assume a user’s manual tab selection changes WebDriver’s context.
The file is missing or the method returns false
Check the process working directory, whether the parent folder exists, and whether the process has write permission. Use an absolute path and create its parent directory. Python’s save_screenshot() returns False on an I/O error; check that return rather than assuming the image was written.
The image is blank or captures an unfinished page
The screenshot may have been taken before navigation or application rendering completed, or the selected tab may not be the intended one. Wait on a meaningful application condition with an explicit wait, verify the active URL and visible content, and then capture. Selenium’s screenshot call does not itself establish that your application’s asynchronous work has finished.
The screenshot contains only part of a long page
Your configured implementation may be capturing a window or visible region rather than the full document. Selenium documents best-effort extent behavior, not a universal full-page result across every browser and driver. Confirm the behavior for the exact setup; if the requirement is a single component, use an element screenshot.
The JavaScript output is not a PNG file
takeScreenshot() returns base64 text. Convert it to a buffer using Buffer.from(base64, 'base64') before writing with Node’s filesystem API. Writing the base64 string directly creates a text file, not a standard PNG image.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated 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 matchBest 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.
Or skip the browser setup
If you need a screenshot of a public URL without managing a Selenium browser session, ScreenshotNeo is a website screenshot API and MCP server. Its one-request endpoint accepts a URL and can return PNG, JPEG, WebP, or PDF. It is not a replacement for Selenium when your test must capture authenticated, session-specific application state or interact with a live browser.
With ScreenshotNeo API documentation, one cURL request looks like this:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; 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 reports its page verdict and billing status in headers. 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 shots.
Sign up free for ScreenshotNeo: 1,000 screenshots a month, no card required.
Frequently Asked Questions
Does Selenium save a screenshot as JPG by default?
No. The documented driver screenshot methods produce PNG image data.
Can I capture a screenshot without saving a file?
Yes. Python provides PNG bytes and base64 output methods, and the JavaScript binding returns base64 PNG data.
Can I screenshot an element rather than the entire application view?
Yes. Locate the element and use its element screenshot method.
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.
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 →




