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 →Use Playwright for Java and set setFullPage(true) on Page.ScreenshotOptions. That instructs the browser to capture the entire scrollable document instead of only the visible viewport, then saves the image to a file (or returns bytes). The approach is explicit, portable across Playwright-supported browsers, and easier to control than a generic WebDriver screenshot.
Capture the complete page with Playwright Java
Playwright defines a full-page screenshot as a screenshot of a full scrollable page, as if the page could fit on a very tall screen. The essential call is:
page.screenshot(new Page.ScreenshotOptions()
.setPath(Paths.get("screenshot.png"))
.setFullPage(true));
setFullPage(true) is the part that changes the capture from the current viewport to the document’s full scrollable height. Without it, the result normally covers only what is visible in the browser window.
A complete Java example
The following context-managed program launches Chromium, opens a URL, and writes a PNG in the current working directory:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →import com.microsoft.playwright.*;
import java.nio.file.Paths;
public class FullPageScreenshot {
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();
}
}
}
Replace the URL with the page you control or are authorized to capture. The example shows the API pattern; use the current Playwright Java installation documentation for your build tool’s dependency coordinates and browser-install command, because those setup details vary by Playwright release.
Save bytes instead of a file
If your application uploads the image, stores it in object storage, or sends it through an API, omit setPath and retain the returned byte array:
byte[] image = page.screenshot(new Page.ScreenshotOptions()
.setFullPage(true));
You can write those bytes with Java NIO, stream them to storage, or return them from a web endpoint. A path is convenient for local jobs; bytes avoid an intermediate file.
Make the capture reproducible
A full-height image can change between runs even when the URL is unchanged. Set a consistent viewport before navigation and control page behavior that is genuinely variable.
- Viewport: create the page with a fixed width and height so responsive breakpoints do not move between runs.
- Waiting: navigate, then wait for a selector, a known application state, or a deliberate delay when content is rendered asynchronously. A screenshot timeout is separate from your application’s own network timeout.
- Animations: disable or fast-forward animations when comparing screenshots. Otherwise a capture can land on a different animation frame.
- Masking: mask clocks, rotating ads, avatars, or other regions that are expected to change. Do not mask content you need to verify.
- Sticky elements: inspect fixed headers and floating controls. During a full-page capture they may appear repeatedly or overlap content, depending on how the page is implemented.
Full-page mode does not magically make every lazy-loaded component appear. Some pages load images or sections only after an element enters the viewport, while others require scrolling events or application-specific API calls. If content is missing, identify the trigger and perform it before taking the screenshot; there is no universal lazy-loading recipe that works for every site.
Output format and screenshot options
Page.ScreenshotOptions exposes the controls needed for production captures:
Rank #2
| Need | Relevant control | Practical note |
|---|---|---|
| Whole document | setFullPage(true) |
Captures the scrollable page rather than just the viewport. |
| File destination | setPath(Paths.get(...)) |
Use a deterministic path in CI or a temporary path for one-off jobs. |
| Image type | PNG, JPEG, or WebP option | PNG preserves lossless detail; JPEG is lossy; WebP can reduce size. |
| JPEG quality | Quality option where supported | Relevant to JPEG output, not PNG. |
| Pixel density | Scale option | Choose deliberately: higher density improves detail but increases bytes and processing. |
| Region | Clip area | Clipping can restrict the result to a rectangle; it is different from full-page capture. |
| Transparency | Transparent-background option | Useful for pages or components designed to render without an opaque background. |
| Variable content | Masking and caret controls | Hide text carets or mask known changing regions for visual tests. |
| Motion | Animation handling | Control transitions when a stable image matters. |
| Time limit | Screenshot timeout | The API reference documents a 30-second default; confirm the default for your exact version. |
Format, quality, and scale change the output characteristics, not the underlying page content. For archival screenshots, PNG is often the safer choice. For large galleries or network transfer, WebP or JPEG may be preferable after checking text and fine-line quality.
Handling difficult pages
Lazy-loaded images
Scroll or otherwise trigger the site’s loading mechanism before capture, then wait until the images have their final dimensions. A fixed delay alone is less reliable than waiting for a selector or application state that proves the content is ready.
Infinite scroll
An infinite-scroll page has no final height until its data-loading condition is satisfied. Decide on a stopping rule (for example, a known item count or an end marker), trigger loading, and only then call setFullPage(true). A full-page flag cannot infer where an intentionally endless feed should end.
Very tall documents
Extremely long pages consume more memory and produce large files. Capture a deliberately bounded region, split the page into sections, lower the scale, or use WebP when a single giant image is not required. Keep the browser and screenshot timeout generous enough for the document’s size, while still failing jobs that hang.
Authentication and private content
Establish the authorized session before the screenshot, using the normal Playwright context, cookies, or login flow for your application. Never place credentials in a URL or commit them to source control. Verify that the resulting image does not expose secrets before sharing it.
Selenium Java: what “screenshot” means
Selenium’s TakesScreenshot interface is a useful alternative when your test suite already uses WebDriver:
File image = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
However, the generic interface does not promise one universal full-document result. For W3C-conformant WebDriver or WebElement implementations, behavior follows the WebDriver specification. For a non-conformant driver, the API describes a best-effort preference: entire page, current window, visible portion of the current frame, then the entire display containing the browser. Consequently, verify the actual browser-driver combination instead of assuming this call always captures the complete document.
If you need Selenium, use a browser- or driver-specific full-page facility where available, or stitch validated viewport captures yourself. Stitching requires care around fixed headers, overlapping regions, device scale, and pages that change while you scroll.
Chromium-only CDP
Chrome DevTools Protocol exposes the Page.captureScreenshot command. CDP is tied to Chromium-based browsers, so it is appropriate when protocol-level control matters and Chromium is an explicit requirement. It is not a browser-portable replacement for Playwright’s cross-browser API, and a complete full-content Java recipe depends on the CDP client and layout strategy you choose.
Choosing an approach
| Approach | Full-page control | Browser scope | Maintenance trade-off |
|---|---|---|---|
| Playwright Java | Explicit with setFullPage(true) |
Playwright-supported browsers | Clear screenshot API and rich options. |
| Selenium Java | Driver-dependent for generic screenshots | WebDriver browsers | Convenient when an existing Selenium suite is in place, but extent must be verified. |
| CDP | Protocol-level, Chromium-specific | Chromium-based browsers | Fine control, at the cost of portability and client-specific code. |
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF, so you do not need to install or maintain a browser in your Java service. Its cleaning steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result.
For Java, call the endpoint with an HTTP client. The same request pattern works from any language:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Java equivalent:
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class ScreenshotNeoShot {
public static void main(String[] args) throws Exception {
String target = "https://stripe.com";
String endpoint = "https://api.screenshotneo.com/v1/shot"
+ "?access_key=YOUR_API_KEY&url="
+ java.net.URLEncoder.encode(target, java.nio.charset.StandardCharsets.UTF_8);
HttpRequest request = HttpRequest.newBuilder(URI.create(endpoint)).GET().build();
HttpResponse response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofByteArray());
Files.write(Path.of("shot.webp"), response.body());
System.out.println(response.headers().map());
}
}
See the ScreenshotNeo documentation for authentication, output and all options. The service also supports full-page capture with lazy images loaded, CSS-selector element shots, dark mode, device presets or custom viewports, retina scale, PDF paper settings and page ranges, HTML/CSS rendering, custom JavaScript, clicks, selector waits, delays, network-idle waits, request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration. AI agents can use its MCP tools: take_screenshot, get_page_info, and capture_pdf.
Plans include 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account.
Rank #4
Troubleshooting
The image contains only the viewport
Confirm that the call uses setFullPage(true) and that you are not replacing it with a clipped rectangle. In Selenium, check the driver’s documented screenshot extent; the generic interface may return only the visible frame.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteLower-page images are blank
The site may lazy-load them. Trigger the required scroll or application state, then wait for the image elements or network activity to settle before capture.
The screenshot times out
Investigate navigation, scripts, fonts, and unusually tall content. Wait for a meaningful readiness condition, increase the screenshot timeout for legitimate work, and fail fast on URLs that never finish.
Runs differ in visual tests
Fix the viewport and browser choice, control animations, wait for dynamic data, and mask only approved volatile regions. Also ensure the test data and timezone are stable.
The file is too large
Choose WebP or JPEG where acceptable, reduce scale, capture a bounded region, or split a very long document. Preserve PNG when lossless text and line detail are more important than size.
Recommended Free Tools
FAQ
Does full-page mode include content below the fold?
Yes, it targets the page’s full scrollable document. Content that the site has not yet loaded still requires site-specific triggering and waiting.
Best Value
Can I capture a single element instead?
Yes. Use Playwright’s locator or element screenshot API when the requirement is a component rather than the entire document; full-page mode is intended for the scrollable page.
Is CDP usable with Firefox or WebKit?
The documented Page.captureScreenshot protocol is Chromium-specific. Choose Playwright when browser portability is a requirement.
Frequently Asked Questions
What is the simplest Java API for a full-height screenshot?
Playwright Java’s page.screenshot(new Page.ScreenshotOptions().setFullPage(true)) call.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteWhy does a full-page screenshot miss lazy content?
Full-page capture measures the document, but a site may load content only after scrolling or another trigger. Perform that trigger and wait for the content before capturing.
Can ScreenshotNeo return formats other than WebP?
Yes. Its endpoint can return PNG, JPEG, WebP, or PDF; consult the documentation for the format parameter and other options.
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.

