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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

A full-page screenshot captures the entire scrollable document—not only the pixels currently visible in the browser window. In Java, Playwright provides the shortest documented solution: navigate to the page and call page.screenshot() with setFullPage(true). If your project already uses Selenium with Chrome, use Chrome DevTools Protocol (CDP) to measure the page and capture an image at that size; Selenium’s generic screenshot method does not guarantee identical full-page behavior across drivers.

What “full page” means

A viewport screenshot records the current browser window. A full-page screenshot expands the capture to the page’s full scrollable content, as if the page were displayed on a screen tall enough to contain it all. The result is normally one tall PNG, JPEG or WebP image. It is different from a PDF: a PDF is paginated and follows print-layout rules, while a full-page image preserves a single continuous canvas.

The page must have loaded enough content before its dimensions are measured or captured. Sites that load images only when they approach the viewport, or that append content during infinite scrolling, may need extra waiting or scrolling logic; a single height measurement cannot prove that undiscovered content has finished loading.

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

Playwright Java: the direct full-page method

Playwright is the practical choice when you can use its Java API. Its screenshot option has an explicit fullPage switch, which is false by default. Set it to true and save the returned image to a path.

Complete runnable example

import com.microsoft.playwright.*;
import java.nio.file.Paths;

public class FullPageShot {
  public static void main(String[] args) {
    try (Playwright playwright = Playwright.create()) {
      Browser browser = playwright.chromium().launch();
      Page page = browser.newPage();

      page.navigate("https://example.com");
      page.screenshot(new Page.ScreenshotOptions()
          .setPath(Paths.get("screenshot.png"))
          .setFullPage(true));

      browser.close();
    }
  }
}

The call writes screenshot.png in the process working directory. Replace the URL and path for your application. In a build or test, use an absolute path or a run-specific directory so parallel jobs do not overwrite one another.

Return bytes instead of writing a file

byte[] png = page.screenshot(new Page.ScreenshotOptions()
    .setFullPage(true));
java.nio.file.Files.write(Paths.get("page.png"), png);

Byte output is useful for pixel comparisons, object storage, HTTP responses or an image-processing pipeline. Playwright also supports screenshots of a locator when you need one component rather than the whole document:

page.locator("main article").screenshot(
    new Locator.ScreenshotOptions()
        .setPath(Paths.get("article.png")));

Wait for application content

Navigation ending does not necessarily mean that your application has rendered its final state. Wait for a stable, meaningful selector before capturing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.navigate("https://example.com/dashboard");
page.waitForSelector("main[data-ready='true']");
page.screenshot(new Page.ScreenshotOptions()
    .setPath(Paths.get("dashboard.png"))
    .setFullPage(true));

Use a selector that your application sets after data and major layout work are complete. A fixed sleep can be useful for a known animation, but a state-based wait is less fragile.

Important Playwright options

  • Scale: device scale captures device pixels and can create very large files on high-DPI contexts. CSS scale keeps one image pixel per CSS pixel and is often smaller.
  • Animation: disable or control animations when deterministic visual tests matter.
  • Masking: mask dynamic regions such as timestamps or avatars before comparison.
  • Clip: capture a rectangle when full-page output is unnecessary.
  • Format and quality: choose the image type and quality appropriate to visual tests versus delivery.

Check the actual output dimensions and inspect pages with fixed headers, sticky navigation, transforms or very long canvases. The API documents the controls, but site-specific CSS can still affect the result.

Selenium: ordinary screenshots versus full-page capture

Selenium exposes TakesScreenshot for drivers and elements:

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import java.nio.file.*;

WebDriver driver = new ChromeDriver();
try {
  driver.get("https://example.com");
  byte[] png = ((TakesScreenshot) driver)
      .getScreenshotAs(OutputType.BYTES);
  Files.write(Paths.get("viewport.png"), png);
} finally {
  driver.quit();
}

This is the standard screenshot API, but do not treat it as a portable full-page switch. Selenium’s documentation describes behavior for non-W3C-conformant drivers as best effort: a driver may prefer the entire page, the current window or visible frame content. Verify the result with the browser and driver combination used by your project.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Selenium with Chrome DevTools Protocol

For an existing Chrome-based Selenium suite, a documented route is to ask Chrome for page layout metrics, set a viewport covering the content dimensions, call the DevTools Page.captureScreenshot command and decode its Base64 result. CDP Java package names are versioned, so use the package matching your Selenium and Chrome versions.

Implementation outline

  1. Navigate and wait for the page’s important content.
  2. Use the DevTools Page domain to obtain the content width and height.
  3. Set the capture viewport to those dimensions.
  4. Capture the page and decode the returned Base64 PNG.
  5. Write the bytes to a file and restore or close the driver.

A Selenium-Jupiter example follows this pattern and writes fullpage-screenshot-chrome.png. Because the generated DevTools classes change with browser protocol versions, copy the equivalent calls for the CDP version resolved by your build rather than mixing bindings from another release.

When this route is appropriate

  • Choose it when Chrome and Selenium are already central to your tests.
  • Choose Playwright when adopting a separate Java browser API is acceptable and you want the concise setFullPage(true) call.
  • Use the generic TakesScreenshot method for ordinary viewport or element captures, not as a promise of cross-driver full-page output.

Make captures complete and repeatable

Lazy-loaded images

Trigger the application’s real loading behavior before capture. Waiting for a key image selector, scrolling through known lazy sections, or using the application’s “loaded” state is safer than assuming navigation alone loaded every image. Infinite-scroll feeds require an explicit stopping rule; otherwise the page may keep growing.

Sticky and fixed elements

Sticky headers can appear repeatedly or cover content in a tall image. If that is a problem, apply capture-only CSS through your browser automation, or hide the selector temporarily. Record such changes in the test so the image’s meaning remains clear.

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

Fonts and animations

Wait for web fonts and disable transitions when visual diffs are sensitive to timing. Dynamic clocks, rotating banners and personalized data should be masked or made deterministic.

Large documents

A very tall raster image consumes memory and may exceed downstream image limits. Consider clipping to meaningful sections, using CSS scale, capturing elements separately, or generating a PDF when a paginated document is the real requirement.

PDF is a different output

Playwright’s page.pdf() creates a paginated document rather than a single tall image. PDF generation uses print CSS media by default; if the screen layout is intended, emulate screen media before generating the PDF. Use PDF for reports, printing and page ranges, and a full-page screenshot for a continuous visual record.

Common failures and fixes

The image contains only the viewport

Cause: setFullPage(true) was omitted, or the Selenium driver only implements viewport capture. Fix: enable Playwright full-page mode, or use the Chrome DevTools dimension-and-capture route.

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

Content is missing below the fold

Cause: lazy loading, infinite scroll or an application request still in progress. Fix: wait for a readiness selector, exercise the lazy-loading path, and define when an infinite feed is complete before measuring height.

The screenshot is unexpectedly huge

Cause: device-pixel scaling or an extremely tall document. Fix: use CSS scale, reduce the capture region, split sections, or choose PDF.

Dynamic regions make visual tests fail

Cause: animations, timestamps, ads or personalized content. Fix: disable animations, mask selectors, stabilize test data and capture after a deterministic readiness signal.

CDP classes do not compile

Cause: the sample’s versioned DevTools package does not match your Selenium dependency or browser. Fix: select the CDP module corresponding to your Selenium version and update imports and command types together.

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

The page never finishes loading

Cause: a third-party request, bot check, broken resource or application error. Fix: set a bounded timeout, log console and network failures, and distinguish an intentionally blocked page from a valid screenshot.

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 is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP or PDF, while its capture flow accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before the shot. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed as clean shots; response headers identify the page verdict and billing result.

Use the API documentation at https://screenshotneo.com/docs/ for all options. A minimal cURL call is:

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 code uses the standard HTTP client:

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.
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;

public class ScreenshotNeoShot {
  public static void main(String[] args) throws Exception {
    String key = "YOUR_API_KEY";
    String target = "https://stripe.com";
    String query = "access_key=" + java.net.URLEncoder.encode(key, java.nio.charset.StandardCharsets.UTF_8)
        + "&url=" + java.net.URLEncoder.encode(target, java.nio.charset.StandardCharsets.UTF_8);
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.screenshotneo.com/v1/shot?" + query))
        .timeout(java.time.Duration.ofSeconds(90))
        .GET().build();
    HttpResponse response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofByteArray());
    if (response.statusCode() / 100 != 2) throw new RuntimeException("HTTP " + response.statusCode());
    Files.write(Paths.get("shot.webp"), response.body());
  }
}

ScreenshotNeo also supports full-page capture with lazy images, CSS-selector element capture, dark mode, device presets and custom viewports, retina or CSS scale, PDF paper settings and page ranges, custom CSS and JavaScript, clicks, selector or network-idle waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting and an OpenAPI specification. Its MCP server exposes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and yearly billing gives two months free. Create a free ScreenshotNeo account.

Quick decision guide

Requirement Best fit Reason
New Java automation and a concise full-page call Playwright Java setFullPage(true) directly requests the full scrollable page.
Existing Chrome Selenium suite Selenium plus CDP Measure content dimensions and capture at that viewport.
Portable ordinary screenshot Selenium TakesScreenshot Standard API, but full-page behavior is driver-dependent.
Paper-like deliverable Playwright PDF Produces paginated output using print media by default.
API or agent workflow without browser maintenance ScreenshotNeo Clean shots, only clean shots billed, and an MCP server.

Frequently Asked Questions

Does Playwright’s full-page option scroll the browser visibly?

It requests an image of the page’s full scrollable content; your automation does not need to perform a manual screen-by-screen scroll.

Can Selenium guarantee one full-page image on every browser?

No. The generic screenshot contract allows best-effort behavior for some drivers. A Chrome-specific DevTools implementation is more explicit, but its bindings are versioned.

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

Should I use PNG or JPEG?

PNG is generally preferable for text-heavy visual tests; JPEG can reduce file size for photographic pages. Choose the format supported by your downstream workflow.

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.