Recommended Free Tools
Use Selenium WebDriver’s TakesScreenshot interface to capture exactly what is visible in the active browser viewport:
File screenshot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
This is a viewport screenshot, not automatically a capture of the entire scrollable page. Selenium can also capture an element, while full-document capture requires a document-area capability or a browser-specific full-page technique.
What Selenium captures
The W3C WebDriver Take Screenshot command captures the visual viewport of the top-level browsing context. In practical terms, that is the browser content currently on screen after the page has loaded, the window has been sized, and any scrolling has positioned the desired content.
| Target | What is included | Java approach |
|---|---|---|
| Current viewport | The visible area of the top-level page | Cast the driver to TakesScreenshot and request OutputType.FILE or BASE64 |
| Element | The visible region of an element’s bounding rectangle after Selenium scrolls it into view | Call the screenshot method on a WebElement |
| Scrollable document | Content extending beyond the current viewport | Use a document-area capability such as WebDriver BiDi where supported, or an explicitly supported full-page method |
The distinction is defined by WebDriver and is also reflected in Selenium’s Java API documentation for TakesScreenshot. A normal driver screenshot should not be described as a full-page image.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Prerequisites
- Java 8 or newer compatible with your Selenium release.
- Selenium WebDriver in your build (Maven, Gradle, or manually managed jars).
- A browser driver that Selenium can start, such as ChromeDriver, GeckoDriver, or a Selenium Manager-supported browser.
- A page loaded in the active top-level window before the screenshot call.
- A writable destination directory if you request a file.
Maven dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>YOUR_SELENIUM_VERSION</version>
</dependency>
Use the Selenium version selected for your project rather than copying an unverified version number. Selenium Manager can supply a compatible driver in current Selenium distributions, but your browser and organizational policies may still require an explicitly installed driver.
Capture the visible viewport to a PNG file
This complete example opens a page, sets a predictable window size, waits for a visible heading, captures the viewport, and copies Selenium’s temporary file to a permanent path.
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.time.Duration;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class VisibleBrowserScreenshot {
public static void main(String[] args) throws Exception {
WebDriver driver = new ChromeDriver();
try {
driver.manage().window().setSize(new org.openqa.selenium.Dimension(1366, 768));
driver.get("https://example.com");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15));
wait.until(ExpectedConditions.visibilityOfElementLocated(
org.openqa.selenium.By.tagName("h1")));
Path destination = Path.of("artifacts", "viewport.png");
Files.createDirectories(destination.getParent());
java.io.File temporary = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
Files.copy(temporary.toPath(), destination,
StandardCopyOption.REPLACE_EXISTING);
System.out.println("Saved " + destination.toAbsolutePath());
} finally {
driver.quit();
}
}
}
Selenium returns a temporary file for OutputType.FILE. Copy it while the driver session is still active or before your test framework removes temporary artifacts. The resulting image dimensions follow the browser’s screenshot behavior, viewport, device scale, and driver implementation; do not assume they equal the CSS window dimensions on every platform.
Request Base64 instead
Use OutputType.BASE64 when an API, database, report, or HTML document needs encoded data instead of a file:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
String imageBase64 = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BASE64);
The Selenium Java API documents the generic getScreenshotAs(OutputType<X>) method and supported output forms. Decode the string with Java’s Base64 utilities only when you need bytes.
Control exactly what is visible
Set the window or viewport size
Set the window size before navigation or capture when reproducible images matter:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
driver.manage().window().setSize(new Dimension(1440, 900));
Headless browsers, operating-system window managers, browser chrome, and device scale can affect the final bitmap. In CI, keep browser, driver, operating system, and scale settings consistent.
Scroll to a position first
A viewport screenshot records the current scroll position. Scroll with JavaScript, then capture:
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →((org.openqa.selenium.JavascriptExecutor) driver)
.executeScript("window.scrollTo(0, 600);");
File shot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
For a stable result, wait for any lazy-loaded content or animations triggered by scrolling. If the page changes while the command runs, the image can reflect an intermediate state.
Wait for readiness
Prefer an explicit wait for a meaningful element over a fixed sleep:
new WebDriverWait(driver, Duration.ofSeconds(15))
.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("main")));
Use a short, targeted delay only for UI transitions that cannot expose a reliable condition. Network completion alone does not guarantee that fonts, images, client-rendered components, or consent dialogs are finished.
Capture one element instead of the whole viewport
When the requirement is a chart, card, form, or other component, capture the element rather than cropping a viewport image:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
WebElement card = new WebDriverWait(driver, Duration.ofSeconds(15))
.until(ExpectedConditions.visibilityOfElementLocated(
By.cssSelector(".pricing-card")));
File elementShot = card.getScreenshotAs(OutputType.FILE);
WebDriver’s element screenshot command scrolls the element into view and captures the visible part of its bounding rectangle. An element taller than the viewport may therefore not produce its complete off-screen contents. The W3C specification defines this behavior separately from the driver-level viewport command.
Element screenshot versus manual cropping
- Use an element screenshot when you want Selenium to locate and scroll to the component.
- Use a viewport screenshot plus image processing when the desired area is defined in pixels or spans several elements.
- Use a full-document method when off-screen content must be included; do not assume an element call stitches a long component.
Viewport, full page, and document screenshots
“Visible browser area” means the viewport. A full-page image is a different deliverable. WebDriver BiDi documentation distinguishes a viewport screenshot area from a document area that includes scrollable content beyond the viewport. See MDN’s browsingContext.captureScreenshot reference for that model.
Support depends on your browser, driver, Selenium version, and the protocol path you choose. The material available here does not establish one universal Java recipe that works identically across every combination. If your acceptance criteria say “entire page,” verify the exact browser and driver implementation and test pages with sticky headers, lazy images, fixed overlays, and very tall content.
Why scrolling and stitching can fail
- Fixed headers or chat controls can appear repeatedly in every tile.
- Lazy images may not load until each section is viewed.
- Animations and carousels can change between captures.
- Very tall documents can exceed image or memory limits.
- Different device scales can create one-pixel seams.
Saving, naming, and test integration
Use deterministic paths
Path destination = Path.of("artifacts", "checkout-viewport.png");
Files.createDirectories(destination.getParent());
Files.copy(((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE).toPath(),
destination,
StandardCopyOption.REPLACE_EXISTING);
Include a test name, browser, viewport, and timestamp in the filename when parallel runs might overwrite one another. Keep screenshots as test artifacts rather than committing generated files to source control.
Attach failures without hiding the original error
In a test teardown or failure hook, attempt the screenshot in a separate try/catch. Log the screenshot failure, but preserve the assertion or navigation exception that caused the test to fail. A closed session, crashed browser, or unwritable directory can make a diagnostic capture impossible.
Troubleshooting
ClassCastException or unsupported screenshot
Cause: the active driver does not implement Selenium’s screenshot interface, or the object being cast is not the actual driver. Fix: cast the WebDriver instance used for navigation to TakesScreenshot; confirm the selected browser driver supports the WebDriver screenshot command.
Image is blank or shows a loading page
Cause: capture happened before rendering completed, after a navigation race, or while a bot check blocked the page. Fix: wait for a specific visible element, verify the URL and page state, and record browser logs or page text before retrying.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Only part of the page appears
That is expected for a viewport screenshot. Scroll before capturing, capture a specific element, or choose a document/full-page capability when off-screen content is required.
Free tools Windows power users keep installed
One-click scans. No signup required.
Element capture misses content
The element is scrolled into view and its visible bounding region is captured; content extending beyond that region or viewport may not be included. Check the element’s dimensions and use a document-oriented approach for long content.
File cannot be copied
Cause: the destination directory does not exist, permissions prevent writing, or a test runner cleans the temporary file too early. Create parent directories, choose a writable artifact directory, and copy immediately after getScreenshotAs returns.
Unexpected dimensions in headless CI
Set the window size explicitly and standardize browser, driver, operating system, and device-scale settings. A CSS viewport size is not always the same as the bitmap’s pixel dimensions.
Consent banners or overlays obscure the page
Dismiss the dialog through a tested locator before capture, or hide it with test-only JavaScript when that reflects your test objective. Do not silently remove user-facing content if the screenshot is meant to document the real visitor experience.
Performance, reliability, and cost considerations
A screenshot command is synchronous from the test’s perspective: the call returns image data only after the driver handles the request. The expensive part is often page startup, rendering, fonts, and network activity rather than writing a small PNG. Reuse a browser session when isolation permits, avoid unnecessary repeated captures, and wait on deterministic conditions instead of long global sleeps.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
For reliable comparisons, fix the viewport, data, locale, timezone, color scheme, browser version, and animation state. Mask timestamps and randomized content. Store the exact URL and test metadata alongside the image so a visual difference can be reproduced.
Or skip the browser setup
If you need a URL screenshot without maintaining Selenium and a browser, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns PNG, JPEG, WebP, or PDF output:
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 documentation for request options. The API can load lazy images for full-page captures, capture a CSS-selected element, set a viewport or device preset, use retina scale, apply custom CSS or JavaScript, click before capture, wait for a selector, delay, or network idle, block ads or resource types, supply headers, cookies, user-agent, authorization, timezone, and geolocation, produce PDFs, resize images, cache with a chosen TTL, create signed image links, run asynchronous jobs with signed webhooks, capture up to 100 URLs per bulk call, and expose usage and OpenAPI endpoints. Its parameter names also accept the names used by other screenshot APIs, which can simplify migration.
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 glitchesBefore capture, ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server supplies take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
The Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; Growth is $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to start with the 1,000 monthly shots.
Java, cURL, Python, and Node.js request examples
Java
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String target = "https://stripe.com";
String encoded = java.net.URLEncoder.encode(target, java.nio.charset.StandardCharsets.UTF_8);
URI uri = URI.create("https://api.screenshotneo.com/v1/shot?access_key=YOUR_API_KEY&url=" + encoded);
HttpResponse<byte[]> response = HttpClient.newHttpClient().send(
HttpRequest.newBuilder(uri).GET().build(),
HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() / 100 != 2) throw new IllegalStateException("HTTP " + response.statusCode());
Files.write(Path.of("shot.webp"), response.body());
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));
Frequently Asked Questions
Does a Selenium viewport screenshot include the browser’s address bar or tabs?
No. WebDriver captures the web content viewport of the top-level browsing context, not the surrounding browser chrome.
Can I request JPEG instead of PNG from Selenium’s Java API?
The standard Selenium Java pattern returns the driver-provided screenshot data; convert the resulting image with an image library if your workflow requires another format.
Should I keep the WebDriver session open after taking the screenshot?
Only as long as your test needs it. Copy or process the returned file immediately, then close the driver in a finally block.
The Bottom Line
For the visible browser area, use ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE) after the page and viewport are ready. Choose element or document-specific capture only when your required bounds extend beyond that viewport.
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.

