Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a reliable full-page screenshot in Java, use an API that explicitly supports the entire scrollable document. In Selenium, FirefoxDriver implements HasFullPageScreenshot; in Playwright Java, call page.screenshot() with setFullPage(true). Selenium’s generic TakesScreenshot method is only best effort and may return the viewport rather than the complete page.

Choose the right Java approach

Approach Full-page behavior Best fit Important limitation
Selenium HasFullPageScreenshot Explicit full-document capture FirefoxDriver in an existing Selenium test suite Not a portable guarantee for every browser driver
Selenium TakesScreenshot Driver-dependent best effort Simple viewport or capability-checked captures May capture only the current window, frame, or visible display
Playwright Java setFullPage(true) Explicit full scrollable page New automation and visual-regression code Dynamic or lazy content still needs suitable waits
Selenium DevTools Page.captureScreenshot Low-level capture with clip and image controls Suites already using compatible DevTools APIs Browser-version setup and page metrics add complexity
AWT Robot Screen rectangle only Visible desktop pixels Does not understand DOM layout or off-screen page content

Capture a full page with Selenium and Firefox

Firefox is Selenium’s clearest full-page route. Create a FirefoxDriver, navigate to the page, cast it to HasFullPageScreenshot, and save the returned file.

Complete Java example

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.firefox.HasFullPageScreenshot;

public class FullPageFirefox {
    public static void main(String[] args) throws Exception {
        FirefoxDriver driver = new FirefoxDriver();
        try {
            driver.get("https://example.com");

            File image = ((HasFullPageScreenshot) driver)
                    .getFullPageScreenshotAs(OutputType.FILE);

            Files.copy(
                    image.toPath(),
                    Path.of("full-page.png"),
                    StandardCopyOption.REPLACE_EXISTING
            );
        } finally {
            driver.quit();
        }
    }
}

OutputType.FILE gives you a temporary file. Copy it to a location under your control before quitting the driver. The finally block closes Firefox even if navigation or file copying fails.

Wait for content before capturing

A navigation call can return while a single-page application is still rendering. Wait for a meaningful element, then capture. Replace the selector with one that identifies your page’s settled state.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
wait.until(ExpectedConditions.visibilityOfElementLocated(
        By.cssSelector("main")
));

For pages that load images when they approach the viewport, application-specific scrolling or an explicit readiness signal may be required. A full-page API cannot infer whether your application has finished injecting content.

Why generic Selenium screenshots may not be full page

The portable Selenium interface is TakesScreenshot:

File image = ((TakesScreenshot) driver)
        .getScreenshotAs(OutputType.FILE);

Selenium describes this as a best-effort operation. A driver may prefer the entire page when it supports that capability, but it can fall back to the current window, visible frame, or display. Treat this method as a viewport capture unless the driver’s documented behavior confirms otherwise.

Check the capability before relying on it

If your test must produce a complete document, use an explicit full-page API such as Firefox’s interface or Playwright’s full-page option. Do not silently label a generic screenshot “full page”; compare the image dimensions or use a known page-height marker as a validation check.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright Java for an explicit full-page capture

Playwright defines a full-page screenshot as the full scrollable page. Set a destination path and enable setFullPage(true).

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Runnable example

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import java.nio.file.Paths;

public class FullPagePlaywright {
    public static void main(String[] args) {
        try (Playwright playwright = Playwright.create()) {
            Browser browser = playwright.chromium().launch(
                    new BrowserType.LaunchOptions().setHeadless(true)
            );
            Page page = browser.newPage();
            page.navigate("https://example.com");
            page.screenshot(new Page.ScreenshotOptions()
                    .setPath(Paths.get("full-page.png"))
                    .setFullPage(true));
            browser.close();
        }
    }
}

Return bytes for image processing

Omit setPath when a visual-diff pipeline needs bytes instead of a file:

byte[] png = page.screenshot(
        new Page.ScreenshotOptions().setFullPage(true)
);

You can then write the bytes, hash them, or send them to an image comparison service. Keep the browser and page lifecycle in a try-with-resources or equivalent cleanup path.

Capture through Selenium DevTools

Selenium’s DevTools Page API exposes Page.captureScreenshot. This lower-level route accepts image format, quality, clipping, and fromSurface settings. It is useful when a suite already depends on DevTools—for example, to capture a specific document rectangle or control JPEG quality—but it requires browser-version-compatible DevTools setup and correct page metrics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because DevTools APIs are browser-specific, prefer Firefox’s explicit interface or Playwright for a straightforward cross-project implementation. Use DevTools when its additional clipping and encoding controls justify the maintenance cost.

Why AWT Robot is usually unsuitable

java.awt.Robot.createScreenCapture(Rectangle) records pixels from a desktop rectangle. It does not know about the DOM, scrollable document height, hidden content, or browser layout. Desktop security permissions can throw SecurityException, and screen capture can be slow. Use Robot for a visible desktop region, not for a deterministic webpage artifact.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Make dynamic pages capture correctly

Wait for navigation and a stable selector

Wait for the element that proves the application has rendered. A URL change alone is not a readiness contract for client-rendered pages.

Handle lazy-loaded images

Full-page capture may expose portions of the document that the user has not yet viewed. If the application loads images only after scrolling, scroll in controlled increments or trigger the application’s documented preload mechanism, then wait for image completion before taking the final shot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Freeze changing content where possible

Animations, rotating banners, timestamps, and live counters can make repeated captures differ. Disable animations with test CSS, mock volatile data, or wait for a stable state. This improves visual diffs and avoids stitching artifacts.

Choose a predictable viewport

Set the same viewport, device scale, locale, timezone, and authentication state for every run. Otherwise a responsive breakpoint or localized text can legitimately change the image dimensions and layout.

Output, performance, and reliability considerations

  • File size: PNG preserves text and edges but can be large for very tall pages. JPEG reduces size but introduces compression artifacts; choose based on testing or archival needs.
  • Memory: A full document is held as one image. Very tall pages can exceed worker memory even when the browser renders them successfully. Split extremely long documents or capture only the required element.
  • Timeouts: Set navigation and wait timeouts long enough for real assets, but keep a bounded upper limit so a failed origin does not stall a test worker indefinitely.
  • Isolation: Use a fresh browser context or profile when cookies, local storage, or permissions could alter the page.
  • Repeatability: Pin browser versions in CI and retain the capture dimensions and URL alongside each artifact.
  • Security: Treat screenshots as sensitive output. They may contain authenticated data, personal information, or secrets rendered by the application.

Troubleshooting full-page Java screenshots

The file contains only the viewport

You used TakesScreenshot or a driver without an explicit full-page implementation. Switch to Firefox’s HasFullPageScreenshot or Playwright’s setFullPage(true).

The bottom of the page is blank

Lazy content may not have loaded, or the page may still be rendering. Wait for a content selector, scroll to trigger loading, and verify network/application readiness before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

The screenshot is cut off or memory usage spikes

The document may be exceptionally tall. Capture a required element, divide the page into sections, or allocate more memory to the worker. Also remove unnecessary third-party content from the test page where possible.

ClassCastException occurs for HasFullPageScreenshot

The active driver does not implement that interface. Do not force the cast; use a supported FirefoxDriver instance, Playwright, or a browser-specific DevTools implementation.

Firefox or the browser fails to start in CI

Check that the browser and driver are installed, executable, and compatible, and run headless when no display server exists. Preserve the startup log because the screenshot API cannot work until the browser session is established.

SecurityException from Robot

Desktop capture permissions block AWT. This is another reason to use a browser-aware full-page API rather than screen pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Images differ between runs

Compare viewport and device scale first, then fonts, locale, timezone, animations, ads, and asynchronous data. Stabilize those inputs before changing screenshot code.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo returns a website screenshot or PDF from one request, including full-page captures with lazy images loaded. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page and billing result in X-Page-Verdict and X-Billed headers. It also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Use the API documentation at https://screenshotneo.com/docs/ for authentication and options. A Java application can call the same HTTP endpoint; cURL, Python, and Node.js examples are below.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Every plan includes the capture options: CSS-selector element shots, dark mode, device presets or custom viewports, retina scale, PDF settings, custom CSS and JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can Selenium take a full-page screenshot in Chrome?

Generic Selenium capture is driver-dependent. If a complete document is mandatory, use an explicit API such as Firefox’s full-page interface, Playwright, or a compatible DevTools implementation rather than assuming Chrome’s generic screenshot is complete.

Can I capture one element instead of the whole page?

Yes. Selenium can locate an element and capture it where the driver supports element screenshots; Playwright and ScreenshotNeo also provide element-oriented workflows. Element capture is often safer for very tall pages.

Should I use PNG or JPEG?

Use PNG for crisp text and pixel comparisons. Use JPEG when smaller files matter more than lossless edges.

Frequently Asked Questions

Can Selenium take a full-page screenshot in Chrome?

Generic Selenium capture is driver-dependent. If a complete document is mandatory, use an explicit API such as Firefox’s full-page interface, Playwright, or a compatible DevTools implementation rather than assuming Chrome’s generic screenshot is complete.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I capture one element instead of the whole page?

Yes. Selenium can locate an element and capture it where the driver supports element screenshots; Playwright and ScreenshotNeo also provide element-oriented workflows. Element capture is often safer for very tall pages.

Should I use PNG or JPEG?

Use PNG for crisp text and pixel comparisons. Use JPEG when smaller files matter more than lossless edges.

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.