Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
For a full-page screenshot in Java, use Selenium’s explicit HasFullPageScreenshot interface with Firefox, or Playwright Java’s setFullPage(true). Selenium’s generic screenshot API is only best-effort: whether it captures beyond the viewport depends on the driver. Choose an explicit full-page API when you need the whole scrollable page.
Use Selenium with Firefox for an explicit full-page capture
Selenium provides HasFullPageScreenshot for full-page screenshots, and FirefoxDriver implements that interface. The following example navigates to a page, saves the returned image as full-page.png, and closes the browser even if capture or file copying fails.
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.firefox.FirefoxDriver;
import org.openqa.selenium.HasFullPageScreenshot;
public class FullPageScreenshot {
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();
}
}
}
This uses Selenium’s Firefox-specific full-page method rather than assuming an ordinary screenshot includes content below the viewport. The file returned by OutputType.FILE is copied to a path you choose; REPLACE_EXISTING lets a rerun overwrite the previous image.
Recommended Free Tools
The example assumes Selenium and a working Firefox WebDriver setup are already available to the Java project. Selenium’s Java documentation also shows the general pattern of using ChromeDriver, TakesScreenshot, and OutputType.FILE, but that generic pattern is not a guarantee of full-page output. Selenium’s screenshot documentation describes the general screenshot interface.
Use Playwright Java when you want a direct full-page option
Playwright exposes full-page capture directly through Page.ScreenshotOptions. Its documentation defines a full-page screenshot as the full scrollable page. Save the image to a path like this:
import java.nio.file.Paths;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
public class PlaywrightFullPageScreenshot {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
try {
Page page = browser.newPage();
page.navigate("https://example.com");
page.screenshot(new Page.ScreenshotOptions()
.setPath(Paths.get("full-page.png"))
.setFullPage(true));
} finally {
browser.close();
}
}
}
}
Playwright’s Java API can also return image bytes if the test needs to pass the capture to a visual-diff tool, upload it, or process it before saving:
byte[] png = page.screenshot();
That byte-array call by itself does not set the full-page option. For an in-memory full-page capture, use the screenshot options and omit the path:
byte[] png = page.screenshot(new Page.ScreenshotOptions()
.setFullPage(true));
See the Playwright Java screenshot documentation for the full-page option and screenshot behavior.
Rank #2
Which Java route should you choose?
| Route | Full-page behavior | Best fit | Trade-off |
|---|---|---|---|
| ScreenshotNeo API | Returns a screenshot or PDF from one HTTP GET request with a URL; full-page capture is an available option. | Developers who want a hosted capture rather than managing browser setup in their Java process. | Requires an API key and network request. ScreenshotNeo documents the API and its capture options. |
Selenium Firefox with HasFullPageScreenshot |
Explicit full-page interface. | Existing Selenium suites that can run Firefox. | Firefox-specific interface; your browser and WebDriver setup must work. |
Selenium generic TakesScreenshot |
Best effort; the actual capture extent depends on the WebDriver implementation. | Tests that need a conventional screenshot and can tolerate driver-dependent scope. | Do not assume it includes the entire page. |
Playwright Java with setFullPage(true) |
Explicitly captures the full scrollable page. | Projects already using Playwright, or Java code that benefits from a direct full-page option. | Requires Playwright browser setup and lifecycle management. |
Selenium DevTools Page.captureScreenshot |
Lower-level screenshot capture with format, quality, clipping, and fromSurface options. |
Suites already using Selenium DevTools that need those lower-level controls. | Requires browser-version-compatible DevTools setup and page-metric handling. |
AWT Robot |
Captures pixels inside a screen rectangle, not a DOM-aware full webpage. | A visible desktop region, rather than a page extending beyond the viewport. | Desktop permissions can cause SecurityException, and the capture call may take time. |
The explicit Selenium Firefox interface and Playwright’s full-page option are the clearest choices when full-page scope matters. Use the generic Selenium API only when its best-effort behavior is acceptable or your specific driver’s behavior has been verified for your use case.
Generic Selenium screenshots: useful, but not a full-page guarantee
If your test only needs the driver’s standard screenshot, the generic Selenium pattern is:
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;
public class DriverScreenshot {
public static void saveScreenshot(WebDriver driver) throws Exception {
File image = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
Files.copy(image.toPath(), Path.of("screenshot.png"),
StandardCopyOption.REPLACE_EXISTING);
}
}
TakesScreenshot describes WebDriver implementations as making a best effort. Depending on what is available, a capture may cover the entire page, the current window, a visible frame, or the display. Treat this as a generic screenshot facility, not as a portable full-page contract. If the captured file stops at the viewport, switch to Firefox’s full-page interface or Playwright’s explicit full-page setting.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows 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 reinstallDevTools capture for lower-level control
Selenium’s DevTools Page API exposes Page.captureScreenshot(...), with options for image format, quality, clipping, and fromSurface. This can suit a test framework that already uses the DevTools protocol and needs to define a specific capture region or image encoding. It is a lower-level route than either framework’s direct full-page interface: browser-version compatibility and page metrics need to be handled as part of the implementation.
For a routine full-page test artifact, start with Firefox’s HasFullPageScreenshot or Playwright’s setFullPage(true). Add DevTools capture when its clip and format controls solve a requirement those APIs do not.
Wait for dynamic content before capturing
A screenshot records what the browser has rendered at capture time. Navigation completing does not necessarily mean that application content, images, or asynchronous updates have settled. Wait for a meaningful page condition before capture rather than relying on an arbitrary delay alone.
- Wait for a page-specific selector that indicates the content is ready.
- For pages that load images lazily as they approach the viewport, use application-specific scrolling or waits so the content is loaded before capture.
- For animations or rapidly changing content, use the site’s test mode or wait for the relevant state to stabilize.
- When debugging a truncated or incomplete image, compare the visible rendered page with the saved image and check whether missing content had loaded before capture.
The exact wait condition depends on the application; there is no universal selector or delay that proves every site is ready.
Or skip the browser setup
ScreenshotNeo can return a screenshot or PDF through one GET request, so a Java service can request a capture without launching a local browser. For example, run this cURL command from a shell:
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
For a Java application, make the same HTTP request with your HTTP client and stream the response bytes to a file. Keep the API key in configuration or a secret store rather than committing it to source control. Review the ScreenshotNeo API documentation for request parameters and response details.
- Cookie and consent banners are accepted and removed before capture; the removal steps can be turned off. Newsletter popups and chat widgets are also removed.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses include
X-Page-VerdictandX-Billedheaders. - An MCP server offers
take_screenshot,get_page_info, andcapture_pdftools for Claude, Cursor, and other MCP clients. - The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to try the API with 1,000 screenshots a month and no card.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting Java full-page captures
The screenshot ends at the viewport
Cause: The code uses generic TakesScreenshot, whose full-page behavior is driver-dependent. Fix: Use Firefox’s HasFullPageScreenshot or Playwright’s setFullPage(true) for an explicit full-page route.
The Firefox cast or method is unavailable
Cause: The active driver is not a FirefoxDriver implementing HasFullPageScreenshot, or the project’s Selenium API setup does not expose the interface used by the code. Fix: Confirm the driver type and Selenium API available to the project; do not cast an arbitrary WebDriver and assume it supports Firefox’s interface. If you are using another browser, use an explicit full-page API supported by that framework, such as Playwright’s option.
Best Value
The image is missing content near the bottom
Cause: Content may not have loaded before capture, especially on a page that defers images until they are near the viewport. Fix: Wait for the content your test needs and, where needed, scroll through the page or use an application-specific loading condition before capturing.
The screenshot file is not where expected
Cause: A relative output path is resolved against the Java process’s working directory, which may differ between an IDE, build tool, and CI runner. Fix: Use an explicit absolute path or log the destination path and verify that the process can write there. Ensure the browser is closed in a finally block or equivalent resource-management path.
An AWT capture throws SecurityException or captures only part of the page
Cause: Robot.createScreenCapture(Rectangle) captures desktop pixels in the specified rectangle, and desktop permissions may block it. Fix: Use a browser automation screenshot API for webpage capture. Reserve Robot for visible desktop regions, not a scrollable DOM page.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Performance, reliability, and cost considerations
With Selenium or Playwright, the Java process is responsible for browser setup and lifecycle, and capture happens after the page is loaded and ready. This is appropriate when screenshots are part of browser tests or need to be produced alongside browser-driven actions. Keep browser cleanup in a guaranteed close path so failed captures do not leave browser processes running.
A hosted API shifts browser execution out of the Java process, but adds an HTTP request and API-key management. ScreenshotNeo charges only for clean shots; failed or unusable captures and cache hits are not billed, with the response headers indicating the verdict and billing status. Its listed plans are Free at 1,000 shots per month, Starter at $5 for 3,000, Growth at $15 for 15,000, Pro at $39 for 60,000, Scale at $99 for 250,000, and Business at $249 for 1,000,000. Yearly billing gives two months free; all features are on every plan. Check the product page for current plan terms before adopting a budget.
Frequently Asked Questions
Can I use Selenium with Chrome to take a full-page screenshot?
The generic Selenium screenshot interface is best effort and does not promise full-page output for every driver. For a portable explicit full-page option in Java, Playwright provides setFullPage(true).
Does Playwright’s setFullPage(true) include the entire scrollable page?
Yes. Playwright’s Java documentation describes this option as capturing the full scrollable page.
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.

