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

To capture a whole webpage—not just the visible viewport—use ChromeDriver to start headless Chrome, load the page, wait for the content you need, then call Chrome DevTools Protocol’s Page.captureScreenshot with captureBeyondViewport: true. Decode the returned base64 data and save it as an image. Chrome’s ordinary --screenshot option is useful for viewport captures, but CDP exposes the specific beyond-viewport setting for full-page automation.

What you need

  • A Chrome installation and a compatible ChromeDriver. Keep their versions compatible with the Selenium and CDP interfaces you use; the sources do not establish a universal minimum version.
  • Selenium with ChromeDriver support in the language used below: Python.
  • A target URL accessible from the machine running the browser.

ChromeDriver configures Chrome through ChromeOptions, including command-line arguments. The ChromeDriver capabilities documentation describes this configuration. CDP provides the actual beyond-viewport capture parameter.

Capture a full page with Python and Selenium

The following example starts headless Chrome, sets a deliberate viewport, navigates to a page, waits for the document to load, requests a beyond-viewport screenshot through CDP, and writes the decoded PNG bytes to disk.

from base64 import b64decode
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait

url = "https://example.com"
output_path = "full-page.png"

options = Options()
options.add_argument("--headless")
options.add_argument("--window-size=1440,900")

driver = webdriver.Chrome(options=options)
try:
    driver.set_page_load_timeout(60)
    driver.get(url)

    # This confirms the document load event, not that every app-specific
    # widget or lazy-loaded section has finished rendering.
    WebDriverWait(driver, 30).until(
        lambda d: d.execute_script("return document.readyState") == "complete"
    )

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

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

print(f"Saved {output_path}")

Change url to the page you need and choose a viewport appropriate for the layout. The viewport width affects responsive design, so a mobile-width capture can differ substantially from a desktop-width one. Chrome’s headless documentation uses --window-size=412,892 as an example, not as a universal recommended size.

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

The CDP Page.captureScreenshot reference documents captureBeyondViewport; its default is false, so set it explicitly. The command returns base64-encoded image data. PNG is used here; CDP also supports JPEG and WebP, and JPEG quality can be configured.

Wait for the page state you actually need

document.readyState == "complete" is a general starting point, not proof that all visual content is ready. Pages can render content asynchronously, load images lazily, or update after scripts run. If your target has a known readiness signal, wait for it instead, such as a specific element appearing or a site-specific state becoming true. A fixed delay can help with a known animation or delayed widget, but it may waste time on fast runs and still be too short on slow ones.

For pages that lazy-load content as you scroll, a single navigation wait may leave lower-page images unloaded. Consider scrolling through the document before the capture, then wait for the relevant images or sections to settle. The exact readiness condition is site-specific; there is no universal wait that guarantees every web application has finished rendering.

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

Why a normal headless screenshot can show only the viewport

Chrome’s --screenshot command-line option saves an image, and its documentation pairs it with --window-size. That is a useful route for a straightforward screenshot, but the documentation does not describe it as a guarantee of arbitrary-document full-page capture. In an automated ChromeDriver workflow, CDP’s captureBeyondViewport parameter is the explicit control for capturing beyond the viewport.

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

ChromeDriver starts and configures the browser session; the CDP command determines the full-page capture behavior. A larger window alone changes the viewport but should not be treated as equivalent to capturing the entire document.

Choose image settings and validate the result

Format

  • PNG: A lossless raster format and the default choice in the example.
  • JPEG: Useful when a lossy image is acceptable; CDP allows a quality setting.
  • WebP: Supported by the protocol and useful where downstream tools accept it.

Dimensions and output checks

After saving, open the file and check that it includes the bottom of the document and the intended responsive layout. Full-page captures can be extremely tall. Practical limits depend on Chrome, the graphics environment, available memory, and the software that will open or process the image; there is no established universal maximum height.

If your browser/client combination requires explicit clipping, query CDP layout metrics and provide a screenshot clip that covers the document. CDP command availability and parameter details are version-sensitive, so consult the protocol reference for the browser session you are running.

When PDF is a better output

If you need a paginated, printable document rather than one tall raster image, use Chrome Headless’s --print-to-pdf path. Chrome documents --no-pdf-header-footer for omitting print headers and footers in current versions; older versions may require the legacy --print-to-pdf-no-header flag. A PDF can follow print styles and paginate content, so it is an alternative format, not an equivalent full-page PNG.

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

Troubleshooting

The file contains only the visible viewport

  • Confirm that the request is using Page.captureScreenshot and explicitly sets "captureBeyondViewport": true.
  • Do not assume that increasing --window-size alone captures the whole document.
  • Check that the Selenium/CDP command interface and the browser version support the parameters you are passing.

The bottom of the page is missing or looks unfinished

  • Navigation completion does not ensure asynchronous content, lazy-loaded images, or widgets are ready.
  • Wait for a meaningful page-specific condition; if content loads on scroll, scroll through the document before taking the screenshot.
  • Inspect the saved image, not just whether the command returned successfully.

Chrome does not start or the CDP command fails

  • Check that ChromeDriver is compatible with the installed Chrome version and that the Selenium client exposes the command invocation used by your code.
  • Review the CDP protocol version available in the active browser session. Protocol references and generated client bindings are versioned; Selenium’s V147 binding is one example, not a minimum-version guarantee.
  • Use the headless argument appropriate to your installed Chrome release rather than relying on a legacy flag without checking version-specific guidance.

The image is too large to open or process

Very long pages can create very tall images, and practical handling limits vary by browser, graphics environment, memory, and image consumer. Capture a narrower scope or use PDF when a paginated artifact is acceptable. No general maximum image height is established here.

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

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. Send one GET request with the page URL to receive an image or PDF. For example, this cURL call saves a WebP screenshot; see the ScreenshotNeo API documentation for parameters and response details.

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

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers indicate the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try it without a card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently asked questions

Can I save the screenshot as JPEG or WebP instead of PNG?

Yes. CDP supports PNG, JPEG, and WebP. Set the format parameter to the desired format; JPEG also supports a quality parameter.

Does the full-page image preserve the page’s print layout?

No. A screenshot captures rendered pixels; print-to-PDF is a separate route that may apply print-specific styling and pagination.

Can Selenium’s generated CDP classes replace the raw command?

Some Selenium releases provide versioned CDP bindings, including a V147 capture setting. The available binding depends on the Selenium/browser protocol versions; keep those aligned and check the API for your installed version.

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.

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