October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Chrome

How to Capture Full-Page Screenshots in Chrome and Safari With Selenium and Java

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

Short answer: Selenium’s Java TakesScreenshot interface is the normal starting point, but it does not guarantee a full-document image. In Chrome, use the version-matched Selenium DevTools binding and Page.captureScreenshot with captureBeyondViewport when available. Safari’s WebDriver screenshot is documented around the current window, so a complete page requires validating your Safari/macOS combination or scrolling through the document and stitching viewport images.

This guide shows both approaches, explains the compatibility limits, and includes complete Java patterns for Chrome, Safari, and a scroll-and-stitch fallback.

What “full-page” means in Selenium

A full-page screenshot contains the document from the top through the bottom, including content outside the current viewport. That is different from a viewport screenshot, which captures only what is visible, and from a current-window screenshot, whose exact coverage depends on the browser driver.

The standard Selenium call is:

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

Selenium documents this as a best-effort operation. Depending on the driver implementation, the result can be the entire page, the current window, or the visible frame. Therefore, the method name alone is not proof that a long page was captured completely. Check the resulting image dimensions and inspect the bottom of the document in your test environment. See the TakesScreenshot Java API and Selenium’s WebDriver screenshot documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

Set up a Java Selenium project

Maven dependencies

Use Selenium Java and, for Chrome full-page capture, the DevTools artifact whose version matches your Selenium release and Chrome protocol binding. DevTools packages are versioned; the v124 API shown in Selenium 4.22.0 documentation is an example of the API shape, not a timeless version recommendation.

<dependencies>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.22.0</version>
  </dependency>
  <!-- Choose the vNNN artifact that matches your Selenium/Chrome setup. -->
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-devtools-v124</artifactId>
    <version>4.22.0</version>
  </dependency>
</dependencies>

Replace the example versions with the versions your project actually supports. Generated DevTools method signatures and package names can change, so consult the API for that exact artifact before compiling.

Driver and browser prerequisites

  • Install a supported Chrome or Safari release and keep the driver/browser combination compatible.
  • For Safari on macOS, enable Develop > Allow Remote Automation in Safari. Apple’s Safari WebDriver documentation describes safaridriver and language-compatible WebDriver clients.
  • Use an explicit wait for the page state you need. A screenshot taken before fonts, images, or lazy sections render is not a reliable page capture.

Chrome: capture the whole document with DevTools

Chrome’s browser-specific route is Selenium’s DevTools session. The Page.captureScreenshot command can request pixels beyond the viewport through the captureBeyondViewport option. Because Selenium generates a separate Java package for each DevTools protocol version, use the package and signature that match your dependency.

Standard viewport screenshot (works across browsers)

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;
import org.openqa.selenium.chrome.ChromeDriver;

public class ViewportShot {
  public static void main(String[] args) throws Exception {
    WebDriver driver = new ChromeDriver();
    try {
      driver.get("https://example.com");
      File temp = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
      Files.copy(temp.toPath(), Path.of("viewport.png"),
          StandardCopyOption.REPLACE_EXISTING);
    } finally {
      driver.quit();
    }
  }
}

This saves Selenium’s temporary file to a predictable path. It does not assert full-document coverage.

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.
Rank #2
SANDISK 128GB Ultra Flair, USB-A Flash Drive, Up to 150MB/s Read Speeds
  • High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
  • Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
  • Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
  • Sleek, durable metal casing
  • Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]

DevTools full-page pattern

The following illustrates the v124-style generated API documented for Selenium 4.22.0. Confirm the exact optional-argument types and import names in your installed DevTools artifact before use.

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.v124.page.Page;

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

      DevTools devTools = driver.getDevTools();
      devTools.createSession();

      // The generated method signature is version-specific. In the matching
      // binding, request captureBeyondViewport=true and PNG output.
      var result = devTools.send(Page.captureScreenshot(
          java.util.Optional.of(Page.Format.PNG),
          java.util.Optional.empty(),
          java.util.Optional.empty(),
          java.util.Optional.of(true),
          java.util.Optional.empty(),
          java.util.Optional.empty()));

      byte[] png = Base64.getDecoder().decode(result);
      Files.write(Path.of("chrome-full-page.png"), png);
    } finally {
      driver.quit();
    }
  }
}

Some Selenium releases expose a different overload or return wrapper. Open the versioned Page API for your artifact and adapt the optional parameters accordingly. The important settings are the Page.captureScreenshot command and captureBeyondViewport=true.

Make Chrome content stable before capture

  1. Navigate to the URL.
  2. Wait for a page-specific readiness condition, such as a main element being visible.
  3. Allow lazy images to load if the page uses intersection observers. You can scroll through the page once, then return to the top, or use a page-specific JavaScript trigger.
  4. Disable animations in a test stylesheet when visual consistency matters.
  5. Capture only after the layout has stopped changing.

DevTools full-page capture is browser-specific. Keep it behind a Chrome implementation rather than assuming the same code works with SafariDriver.

Safari: WebDriver screenshot and its limits

Instantiate SafariDriver through Selenium’s normal Java API and use TakesScreenshot for the current browsing context:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
2 Pack 64GB USB Flash Drive USB 2.0 Thumb Drives Jump Drive Fold Storage Memory Stick Swivel Design - Black
  • What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
  • Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
  • Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
  • Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
  • Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
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.safari.SafariDriver;

public class SafariShot {
  public static void main(String[] args) throws Exception {
    SafariDriver driver = new SafariDriver();
    try {
      driver.get("https://example.com");
      File temp = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
      Files.copy(temp.toPath(), Path.of("safari-window.png"),
          StandardCopyOption.REPLACE_EXISTING);
    } finally {
      driver.quit();
    }
  }
}

The cited Safari API describes a current-window screenshot; the available documentation does not establish one universal Java command that captures the entire scrollable document on every Safari release. Treat full-page coverage as something to verify on the exact Safari and macOS versions you deploy.

Safari fallback: scroll and stitch viewport images

When a complete Safari image is mandatory and the native result is only a window, capture successive viewport regions and combine them with an image library such as Java’s BufferedImage. The automation portion below records each viewport; the final composition should account for the actual device-pixel ratio and image dimensions.

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.safari.SafariDriver;

public class SafariScrollCapture {
  public static void main(String[] args) throws Exception {
    SafariDriver driver = new SafariDriver();
    List<Path> parts = new ArrayList<>();
    try {
      driver.get("https://example.com/long-page");
      JavascriptExecutor js = driver;
      long pageHeight = ((Number) js.executeScript(
          "return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);"))
          .longValue();
      long viewport = ((Number) js.executeScript("return window.innerHeight;") )
          .longValue();

      int index = 0;
      for (long y = 0; y < pageHeight; y += viewport) {
        js.executeScript("window.scrollTo(0, arguments[0]);", y);
        Thread.sleep(250); // replace with an explicit readiness wait when possible
        File temp = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        Path part = Path.of("safari-part-" + index++ + ".png");
        Files.copy(temp.toPath(), part);
        parts.add(part);
      }
      // Stitch parts with your chosen image library, removing any overlap.
      System.out.println("Captured " + parts.size() + " viewport images");
    } finally {
      driver.quit();
    }
  }
}

Use the scroll position as a control value, not as proof that each image has identical content. Sticky headers may be repeated; lazy loading can change document height; animations and responsive reflow can create seams; and a final viewport is often shorter than the others. Hide or compensate for fixed elements, wait for newly revealed content, and crop overlap during stitching. Validate the stitched image visually and by checking that the bottom-most content is present.

Choosing the right implementation

Need Recommended route Qualification
Quick visible screenshot in Chrome or Safari TakesScreenshot Coverage follows the driver; commonly the current window or viewport.
Chrome whole-document image DevTools Page.captureScreenshot with captureBeyondViewport Match the generated DevTools package to Selenium and Chrome.
Safari whole-document image Validate native output; otherwise scroll and stitch No universal Safari full-page Java method is established by the cited sources.
Cross-browser reproducible service output Use an API after defining your page-readiness and validation rules External services have their own rendering and billing semantics.

Common failures and fixes

The image stops at the viewport

Cause: the driver returned a current-window capture. Fix: use Chrome DevTools with the beyond-viewport option, or implement Safari scrolling and stitching. Do not label a viewport image “full page.”

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

DevTools imports or methods do not compile

Cause: the vNNN package or method signature does not match your Selenium dependency. Fix: align the DevTools artifact with the Selenium release and inspect that version’s generated Page.captureScreenshot documentation. The v124 example is tied to Selenium 4.22.0 documentation.

Rank #4
SIMMAX 32GB Memory Stick USB 2.0 Flash Drives Swivel Thumb Drive Pen Drive (32GB Purple)
  • GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
  • BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
  • EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
  • TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
  • WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.

Chrome returns a blank or incomplete image

Cause: capture occurred before navigation, fonts, images, or lazy sections finished. Fix: wait for a meaningful DOM condition, exercise lazy loading, and capture after layout settles. Also check that the page did not redirect to a bot check or authentication screen.

Safari automation cannot connect

Cause: Remote Automation is disabled or macOS permissions/configuration are incomplete. Fix: enable Safari’s Develop menu setting for remote automation, then retry with a compatible Selenium client and Safari release.

Stitched images have gaps, overlaps, or repeated headers

Cause: sticky elements, changing page height, device-pixel scaling, or scrolling during animation. Fix: freeze animations, hide or crop fixed elements, wait after each scroll, calculate overlap from actual image dimensions, and compare the final bottom edge with the document.

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

Content differs between runs

Cause: responsive breakpoints, time-dependent content, personalization, or network-loaded assets. Fix: set a deterministic window size, locale and test data where possible, wait for network-dependent components, and record browser, OS, viewport, and device scale with each artifact.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

  • A single DevTools capture is usually cheaper in test time than stitching many images, but it is limited to Chrome and its protocol compatibility.
  • Scroll-and-stitch increases work roughly with the number of viewport heights in the document and requires image decoding and composition memory.
  • Long pages with large images can exceed practical image dimensions or memory limits. Split the page into sections when your downstream system has size limits.
  • Run a coverage assertion: verify the captured image’s expected width, inspect a known bottom marker, and fail the test when the marker is missing.
  • Store browser and driver versions alongside screenshots so a rendering change can be diagnosed rather than mistaken for a stitching bug.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server for developers. One GET request returns PNG, JPEG, WebP, or PDF, and it handles common capture cleanup before billing: cookie and consent banners, newsletter popups, and chat widgets from more than 60 known platforms are removed when those steps are enabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; the response reports the page verdict and billing status in X-Page-Verdict and X-Billed headers.

For a direct full-page request, see the ScreenshotNeo documentation:

Best Value
Sale
IMEASON Swivel Design 16GB USB Flash Drive with Keychain, USB 2.0 Portable Thumb Drive Memory Stick, FAT32 Format Flashdrive for Data Storage, Photos, Music, Files (Black, 16 GB)
  • 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
  • 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
  • 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
  • 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
  • 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Equivalent Java-friendly calls from a build or test harness can use any HTTP client. The API also supports element selectors, dark mode, device presets and custom viewports, retina scale, PDF paper and page options, custom CSS and JavaScript, click and wait conditions, blocked requests, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage data, and an OpenAPI specification. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

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

Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 screenshots. Every feature is available on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to try it without a card.

Validation checklist

  • Confirm whether your output is viewport, current-window, or full-document.
  • Record browser, browser-driver, Selenium, DevTools binding, operating-system, viewport, and scale versions.
  • Wait for the specific page state that makes the screenshot meaningful.
  • Exercise lazy-loaded content before capture.
  • Check the image’s bottom edge and expected dimensions.
  • For Safari stitching, test sticky elements, reflow, overlap, and the final partial viewport.
  • Keep version-specific Chrome DevTools code isolated so upgrades are easy to repair.

Frequently Asked Questions

Does Selenium’s standard screenshot method always capture the entire page?

No. Selenium documents browser-dependent, best-effort coverage that can be the full page, current window, or visible frame. Verify the actual output.

Can the Chrome DevTools example be copied unchanged into any Selenium project?

No. DevTools Java packages and method signatures are versioned. Match the generated package to your Selenium release and inspect that binding’s API.

Is Safari full-page capture guaranteed by SafariDriver?

The cited Safari documentation describes current-window screenshots, not a universal whole-document guarantee. Validate your Safari/macOS deployment or use scroll-and-stitch.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.