Implementation:SeleniumHQ Selenium HasFullPageScreenshot
| Knowledge Sources | |
|---|---|
| Domains | WebDriver, Firefox_Browser |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
HasFullPageScreenshot is a Beta interface that enables capturing a screenshot of the entire page, including content below the visible viewport, in Firefox.
Description
The HasFullPageScreenshot interface, annotated with @Beta, declares a single method getFullPageScreenshotAs() that captures a full-page screenshot of the current document. Unlike the standard WebDriver TakesScreenshot interface which only captures the visible viewport, this Firefox-specific capability scrolls through and stitches together the entire page content into a single image. The method is generic, accepting an OutputType<X> parameter that determines the return format (e.g., OutputType.FILE for a temporary file, OutputType.BASE64 for a Base64-encoded string, or OutputType.BYTES for raw byte data). This capability operates through the geckodriver/Marionette protocol's full-page screenshot command.
Usage
Use HasFullPageScreenshot when you need to capture the complete content of a web page that extends beyond the visible browser viewport, such as for visual regression testing of long pages, generating page previews, or archiving full page content. Cast your FirefoxDriver instance to HasFullPageScreenshot to access this method.
Code Reference
Source Location
- Repository: SeleniumHQ_Selenium
- File: java/src/org/openqa/selenium/firefox/HasFullPageScreenshot.java
Signature
@Beta
public interface HasFullPageScreenshot {
<X> X getFullPageScreenshotAs(OutputType<X> outputType);
}
Import
import org.openqa.selenium.firefox.HasFullPageScreenshot;
I/O Contract
Methods
| Method | Input | Output | Description |
|---|---|---|---|
getFullPageScreenshotAs |
OutputType<X> outputType |
X (type determined by OutputType) |
Captures a full-page screenshot of the entire document, including content outside the visible viewport, and returns it in the specified format. |
Output Types
| OutputType | Return Type | Description |
|---|---|---|
OutputType.FILE |
File |
Returns a temporary file containing the screenshot image (PNG format). |
OutputType.BASE64 |
String |
Returns the screenshot as a Base64-encoded string. |
OutputType.BYTES |
byte[] |
Returns the screenshot as raw byte data. |
Usage Examples
// Capture a full page screenshot as a File
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://example.com/long-page");
HasFullPageScreenshot screenshotDriver = (HasFullPageScreenshot) driver;
File screenshot = screenshotDriver.getFullPageScreenshotAs(OutputType.FILE);
System.out.println("Screenshot saved to: " + screenshot.getAbsolutePath());
// Capture as Base64-encoded string
HasFullPageScreenshot screenshotDriver = (HasFullPageScreenshot) driver;
String base64Screenshot = screenshotDriver.getFullPageScreenshotAs(OutputType.BASE64);
// Capture as raw bytes and save to a specific location
HasFullPageScreenshot screenshotDriver = (HasFullPageScreenshot) driver;
byte[] screenshotBytes = screenshotDriver.getFullPageScreenshotAs(OutputType.BYTES);
Files.write(Path.of("full-page-screenshot.png"), screenshotBytes);
// Compare with standard viewport-only screenshot
FirefoxDriver driver = new FirefoxDriver();
driver.get("https://example.com/long-page");
// Standard viewport screenshot (only visible area)
File viewportShot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
// Full page screenshot (entire document including scrollable content)
File fullPageShot = ((HasFullPageScreenshot) driver).getFullPageScreenshotAs(OutputType.FILE);
Related Pages
- FirefoxDriver - Implements
HasFullPageScreenshotfor full-page capture - HasContext - Another Firefox-specific capability interface
- HasExtensions - Another Firefox-specific capability interface
- FirefoxOptions - Configuration options for Firefox sessions
- GeckoDriverService - Manages the geckodriver process that supports full-page screenshots