Best Ways to Capture Full-Page Screenshots with Selenium and Chrome
Capture a whole page with Selenium and Chrome. Compare WebDriver, Chrome DevTools, and binding-specific options, with runnable examples and troubleshooting.
To capture a full page with Selenium and Chrome, first try the standard WebDriver screenshot call for your language binding, then inspect the resulting image to confirm it includes content below the fold. If it captures only the viewport, use a documented full-page option supported by your binding or a Chrome DevTools Protocol (CDP) capture route. These APIs vary by language, Selenium version, and browser support, so no one call is guaranteed to work across every Selenium and Chrome combination.
For production captures, record your Selenium, Chrome, and driver versions and verify output on the pages that matter. A larger or maximized browser window can capture more visible content, but Selenium’s window sizing documentation does not establish it as a guarantee of whole-document capture.
1. Try the standard Selenium screenshot call
The ordinary WebDriver screenshot API is the simplest place to start. Selenium’s JavaScript API describes taking a screenshot of the current page and puts whole-page capture first in its best-effort behavior. That wording is not a promise that every browser, driver, or binding will capture the full document. Check the actual image dimensions and confirm that content below the viewport appears.
Python: save a screenshot with Selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless=new")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
# Replace this with an application-specific readiness condition
# when the page renders content asynchronously.
driver.save_screenshot("page.png")
finally:
driver.quit()
This is runnable with a Selenium Python installation and a Chrome/ChromeDriver setup supported by that installation. The call writes a PNG. It does not establish that the image covers the entire document: inspect the result for your browser and driver version.
JavaScript: get the screenshot as PNG data
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const fs = require('node:fs/promises');
(async () => {
const options = new chrome.Options().addArguments('--headless=new');
const driver = await new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
try {
await driver.get('https://example.com');
// Add an application-specific wait if the page renders asynchronously.
const pngBase64 = await driver.takeScreenshot();
await fs.writeFile('page.png', Buffer.from(pngBase64, 'base64'));
} finally {
await driver.quit();
}
})();
The JavaScript API returns PNG data encoded as base64. Its documentation describes the capture as best effort; verify that it includes below-viewport content in your setup. See Selenium’s JavaScript WebDriver API.
Ruby: use the documented full-page option where supported
require "selenium-webdriver"
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--headless=new")
driver = Selenium::WebDriver.for(:chrome, options: options)
begin
driver.navigate.to("https://example.com")
driver.save_screenshot("page.png", full_page: true)
ensure
driver.quit
end
The Ruby screenshot API documents full_page: true where the driver supports the facility. A driver that cannot provide it may raise UnsupportedOperationError. The related FullPageScreenshot extension is labeled private API, so do not treat it as a stable, universal interface. See the Ruby screenshot API and the Ruby full-page extension reference.
2. Use Chrome DevTools when you need explicit beyond-viewport control
Chrome DevTools Protocol offers browser-specific capture controls. Selenium’s .NET V148 DevTools reference documents CaptureBeyondViewport on CaptureScreenshotCommandSettings, with a default of false. The settings also expose a clip rectangle, image format, source surface, JPEG quality, and an encoding speed-versus-size choice.
This is a versioned, binding-specific API, not part of a portable WebDriver screenshot contract. The cited reference does not establish a universal call pattern for every Selenium language binding. Use the DevTools integration documented for your exact Selenium binding and version, and ensure its generated protocol support matches the Chrome version you run. For clip coordinates, the .NET DevTools reference describes rectangle values in device-independent pixels.
The available reference documents settings rather than a universal end-to-end program for all bindings. Avoid copying a DevTools call from another Selenium version or language without checking that binding’s generated API. Start with the official Selenium .NET V148 capture settings and its corresponding viewport reference.
Choosing between the routes
| Route | Good starting point for | Limit to account for |
|---|---|---|
| Standard WebDriver screenshot | A simple, familiar first attempt in a Selenium binding | Full-page behavior depends on implementation; the JavaScript API calls it best effort |
| Chrome DevTools capture | Chrome-specific control such as capture beyond the viewport or a clip | Versioned protocol integration; binding and Chrome compatibility matter |
| Binding-specific full-page option | A documented convenience option, such as Ruby’s full_page: true |
Availability varies; unsupported operation is possible |
| Enlarge or maximize the window | Capturing a larger viewport or a viewport-based comparison | Changing window dimensions is not documented as a full-document guarantee |
3. Prepare the page and verify what you captured
- Record the stack. Note the Selenium binding and version, Chrome version, and driver version. This makes version-sensitive results reproducible.
- Wait for the page state you need. Use a meaningful application signal, such as a target element becoming visible or data appearing. There is no universal readiness condition or fixed wait established by the cited sources.
- Capture with the standard API. Save the result in the format the API provides and inspect it.
- Check below-the-fold coverage. Confirm the image contains the page sections your task needs. Distinguish a viewport screenshot, an element screenshot, a clipped region, and a beyond-viewport page capture.
- Switch routes only if needed. Use a documented binding-specific full-page option or the DevTools API supported by your stack.
- Keep a representative validation set. Recheck pages with different layouts and loading behavior when changing browser, driver, or Selenium versions.
Pages that render content dynamically or lazily can make the visible result depend on when capture runs. The cited documentation does not specify how all such page behaviors affect screenshots. Determine the required ready state for your site and inspect the output rather than assuming a fixed delay solves it.
4. Troubleshooting
| Symptom | Likely cause | What to do |
|---|---|---|
| The image stops at the visible viewport | The current WebDriver/driver route returned a viewport capture, or its full-page behavior is unsupported | Inspect actual output; try a documented full-page option for your binding or a compatible Chrome DevTools beyond-viewport route |
Ruby raises UnsupportedOperationError |
The driver does not support the requested full-page facility | Use another documented route for your stack; do not assume the private extension is universally available |
| DevTools settings or command are missing | The installed Selenium binding/version may not expose that protocol type, or the browser and generated protocol versions may not align | Check the generated API for your exact Selenium version and its compatibility with Chrome; follow that version’s binding documentation |
| Lower sections are empty or incomplete | Capture may have happened before the page reached the state needed by your task | Wait on an application-specific condition, then capture again and inspect the image |
| Resizing the window did not capture the full document | Window size controls the viewport; it does not by itself guarantee full-page capture | Use a full-page-capable route and validate the resulting dimensions and content |
| A clipped image is offset or has unexpected size | Clip coordinates, scale, or viewport assumptions do not match the desired region | Check the binding’s documented coordinate units and clip settings; the cited .NET reference describes clip coordinates in device-independent pixels |
5. Performance, reliability, and cost
A full-page image contains more content than a viewport image, so the amount of page rendered and image data produced can differ. The supplied Selenium references provide no numeric limits, runtime comparisons, or reliability rates; do not assume a particular capture time or maximum page height from them. For a repeatable workflow, wait for the state you need, use one capture route consistently, preserve version details, and inspect output after stack changes.
With a self-hosted Selenium setup, account for your own browser and driver execution resources and maintenance. Selenium’s cited API documentation does not specify service pricing. The DevTools route adds version compatibility work; a binding-specific convenience option can be simpler where supported.
Or skip the browser setup
If you need screenshots without maintaining a Selenium browser session, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns an image or PDF. Its clean-capture steps accept cookie and consent banners like a visitor, then remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for setup and options. There is no card required for 1,000 screenshots per month; paid plans start at $5 for 3,000, and every feature is on every plan. Create a free account and get 1,000 screenshots a month with no card.
FAQ
Does maximizing Chrome guarantee a full-page screenshot?
No such guarantee is established by Selenium’s window documentation. Maximizing changes the window dimensions; check the resulting image or use a documented full-page capture route.
Is Chrome DevTools capture portable to Firefox?
The DevTools method described here is Chrome-specific. Use APIs documented for the browser and Selenium binding in your own stack.
Should I use Selenium’s Ruby private full-page extension?
The extension is explicitly labeled private API, so its stability should not be assumed. Prefer a documented option supported by your binding and driver.
What image format does the basic JavaScript screenshot call return?
Selenium’s JavaScript WebDriver API documents PNG screenshot data encoded as base64.


