DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

How to Take Full-Page Screenshots with ChromeDriver in Headless Mode

Use ChromeDriver to launch headless Chrome, then call CDP Page.captureScreenshot with captureBeyondViewport enabled to save a full-page image.

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.

Use ChromeDriver to start headless Chrome, let the page reach the state you need, then call Chrome DevTools Protocol’s Page.captureScreenshot with captureBeyondViewport: true. Decode the returned base64 data and save it as an image. That explicit CDP option is the key: an ordinary viewport screenshot does not include the rest of a long page.

Capture the whole page with ChromeDriver and CDP

The steps below use Python with Selenium 4. The browser session is created through ChromeDriver; the screenshot itself is requested through CDP. ChromeDriver accepts Chrome startup arguments through ChromeOptions, while CDP provides the beyond-viewport capture setting. See the ChromeDriver capabilities documentation and the CDP Page.captureScreenshot reference.

As an Amazon Associate I earn from qualifying purchases.

1. Install Selenium and prepare compatible browser components

Install Selenium with python -m pip install selenium. Use a ChromeDriver compatible with the Chrome version installed on your system. The exact version pair and minimum supported version depend on the browser and client; no universal minimum is established here.

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.

2. Run a full-page capture

Save this as full_page.py. Set PAGE_URL to the page to capture and adjust VIEWPORT_WIDTH to the layout you want. The viewport width matters because responsive pages can render differently at different widths.

import base64
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

PAGE_URL = "https://example.com"
OUTPUT_FILE = "full-page.png"
VIEWPORT_WIDTH = 1440
VIEWPORT_HEIGHT = 1000

options = Options()
options.add_argument("--headless")
options.add_argument(f"--window-size={VIEWPORT_WIDTH},{VIEWPORT_HEIGHT}")

driver = webdriver.Chrome(options=options)
try:
    driver.get(PAGE_URL)

    # Replace or supplement this delay with a condition that reflects
    # when the specific page's important content has rendered.
    time.sleep(2)

    result = driver.execute_cdp_cmd(
        "Page.captureScreenshot",
        {
            "format": "png",
            "captureBeyondViewport": True,
        },
    )

    with open(OUTPUT_FILE, "wb") as image_file:
        image_file.write(base64.b64decode(result["data"]))
finally:
    driver.quit()

Run it with python full_page.py. The returned CDP data field is base64-encoded image content; decoding it produces the PNG bytes written to disk. The protocol also supports JPEG and WebP, and allows JPEG quality to be specified. Check the protocol available in the actual browser session because CDP and generated client bindings evolve.

3. Confirm the result

  • Open the saved image and check that it includes content near the document bottom.
  • Check the image width and page layout against the intended desktop or mobile viewport.
  • Look for missing images, unrendered text, or overlays that indicate the page was captured before it settled.

Why a normal headless screenshot may show only the viewport

Chrome’s headless command-line documentation describes --screenshot as saving a screenshot of the target page, and shows --window-size as a useful companion. That is useful for a viewport-sized capture, but the documentation does not present the flag as a general guarantee of arbitrary-document full-page capture. CDP’s Page.captureScreenshot has a separate captureBeyondViewport parameter, whose documented default is false; set it to true when the capture must extend beyond the viewport. See Chrome’s headless command-line reference and the CDP parameter documentation.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Wait for meaningful page content, not just navigation

A successful navigation does not guarantee that every image, font, lazy-loaded section, or asynchronous widget has finished rendering. A fixed delay, as in the example, is simple but can be too short on a slow page and waste time on a fast one. Prefer a readiness condition that matches the page you are capturing—for example, waiting for a known content element or for an application-specific state—then use a sensible upper time limit so a failure does not wait indefinitely.

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

For pages that load content as the visitor scrolls, merely waiting after navigation may not trigger lazy-loaded sections farther down the document. Check the resulting image. If sections or images are absent, use a page-specific approach to trigger their loading before taking the screenshot, then wait for those elements to appear. A timeout limits how long a capture process waits; it does not prove that the page’s dynamic content is complete.

When explicit clipping or another output format makes sense

Use a CDP clip only when you need to control the captured rectangle

A basic capture can request captureBeyondViewport: true directly. If the browser/client combination requires explicit clipping, query CDP page layout metrics and pass a clip covering the document dimensions. The relevant layout and screenshot parameters are version-sensitive, so check the protocol version available in the browser session and its matching documentation rather than assuming every client exposes identical command types.

Choose PDF for a paginated document

For a printable, paginated artifact rather than one tall raster image, Chrome Headless supports --print-to-pdf. Current Chrome documentation also describes --no-pdf-header-footer for omitting print headers and footers; older versions may use --print-to-pdf-no-header. A PDF can follow print styling and page breaks, so it is an alternative format, not an equivalent full-page PNG. See the Chrome Headless reference.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Version and practical limits

CDP follows Chromium’s evolving protocol, and Selenium’s generated bindings are versioned. For example, Selenium documentation has a V147 binding with a CaptureBeyondViewport setting; that does not establish a minimum version for every setup. The direct execute_cdp_cmd pattern shown above also depends on the commands supported by the Chrome session you start. Keep Chrome, ChromeDriver, and Selenium aligned, and consult the version-matched documentation if a command or parameter is rejected.

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

Very long documents can create very tall images. The practical limit depends on Chrome, the graphics environment, available memory, and the software that will open or process the result. There is no general maximum image height established here, so inspect the output and consider PDF or capturing smaller sections if a single image is unwieldy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • Only the visible viewport appears: Make sure the command is Page.captureScreenshot and explicitly sets captureBeyondViewport to true. A normal screenshot path may capture only the viewport.
  • The CDP command or parameter is rejected: Check the protocol supported by the active Chrome session and the Selenium binding you are using. CDP evolves, and versioned bindings may expose different names or settings.
  • Chrome fails to start or ChromeDriver reports a session error: Confirm that ChromeDriver is compatible with the installed Chrome, and that the Chrome options are accepted by that release.
  • The bottom of the page is blank or images are missing: Wait for the page’s actual content state, and trigger lazy loading where needed. Navigation completion or a short fixed delay alone may not be sufficient.
  • The layout is unexpectedly narrow or rearranged: Set an intentional window size before navigation; viewport width can change responsive breakpoints and page layout.
  • The output is too large to handle: Reduce the capture scope or use a paginated PDF if it fits the use case. Tall-image handling varies by browser environment and downstream image tools.

Or skip the browser setup

For a one-request screenshot, ScreenshotNeo returns an image or PDF from a URL. Its API removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also provides an MCP server so AI agents can take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

See the ScreenshotNeo API documentation. This cURL example saves a WebP screenshot:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

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

Frequently Asked Questions

Can I save the result as JPEG instead of PNG?

Yes. CDP supports JPEG and WebP as well as PNG; set the capture format accordingly, and use the protocol’s JPEG quality option if needed.

Does `–window-size` make a capture full-page?

It sets the browser window dimensions and influences the viewport and responsive layout; use CDP’s `captureBeyondViewport` option for the explicit beyond-viewport capture behavior.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.