Use Selenium’s standard screenshot command for routine, portable test evidence; use Chrome DevTools Protocol (CDP) when you need Chrome-specific options such as a crop region, image format, JPEG quality, or a request to capture beyond the viewport. Neither choice guarantees a reliable full-page image on every page: verify the result in the browser and page you actually target.
What the two screenshot methods are
Selenium exposes the WebDriver screenshot command through its language bindings. The W3C WebDriver specification defines it as a screenshot of the top-level browsing context’s visual viewport. Selenium also offers a separate element screenshot operation. W3C WebDriver specification, screen capture; Selenium screenshot documentation.
CDP’s Page.captureScreenshot is a Chrome DevTools Protocol command. It accepts options for the output format, JPEG quality, an optional clip rectangle, and whether to request capture beyond the viewport. In the current protocol documentation, captureBeyondViewport defaults to false. The Selenium-maintained Chromium v136 protocol definition labels that option experimental; check the protocol version paired with your browser rather than assuming that snapshot describes every Chrome release. CDP Page.captureScreenshot; Selenium’s Chromium v136 protocol definition.
At a glance: Selenium WebDriver vs. CDP
| Decision | Selenium WebDriver screenshot | CDP Page.captureScreenshot |
|---|---|---|
| Interface | Standard WebDriver screenshot command exposed by Selenium bindings. | Chrome DevTools Protocol Page-domain command. |
| Default scope | Top-level browsing context’s visual viewport. | Page screenshot; beyond-viewport capture defaults to false in current protocol documentation. |
| Element or region | A separate element screenshot captures the visible region after scrolling the element into view. | An optional clip rectangle specifies a region. |
| Image settings | Core command captures an image; Selenium’s documented examples save screenshots to common image files. | Supports PNG, JPEG, or WebP; JPEG quality is configurable. |
| Portability | The natural starting point for a WebDriver-based multi-browser workflow, because WebDriver is a W3C standard. | Chrome-specific; support depends on the browser, protocol version, and client used to send the command. |
| Full-page capture | The standard command is viewport-based; capturing the full document requires another supported mechanism or a workaround. | Offers captureBeyondViewport, but behavior needs validation on the target page and browser. |
Choose the method for the evidence you need
Use Selenium’s standard screenshot command for routine test output
If your test already runs through WebDriver and you want a viewport image for a test artifact, bug report, or failure record, the standard command keeps capture in the same workflow. Selenium documents screenshot APIs for Python, Java, C#, Ruby, JavaScript, and Kotlin. Selenium screenshot documentation.
#1 Best Overall
Use an element screenshot for focused evidence
When you need one visible component rather than the whole viewport, use WebDriver’s element screenshot operation. The specification describes capturing the visible region of the element’s bounding rectangle after it has been scrolled into view. This is distinct from the driver-level viewport screenshot. W3C WebDriver specification, screen capture.
Use CDP when its Chrome-specific controls matter
Choose Page.captureScreenshot if you need a clip rectangle, a choice of PNG, JPEG, or WebP, configurable JPEG quality, or a beyond-viewport request. These controls are useful when the capture requirements are specific enough to justify using Chrome’s protocol rather than WebDriver’s standard screenshot command. CDP Page.captureScreenshot.
Take a viewport screenshot with Selenium in Python
This minimal example opens a page, saves the current visual viewport to page.png, and closes the browser:
Rank #2
from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
driver.save_screenshot("page.png")
finally:
driver.quit()
The leading spaces before driver in a copied code block can cause an indentation error at module level. Use this correctly aligned version to run it:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →from selenium import webdriver
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
driver.save_screenshot("page.png")
finally:
driver.quit()
For an element-level capture, locate the element and call its screenshot method, for example element.screenshot("element.png"). The exact API spelling and return format can vary by language binding; consult the relevant Selenium binding documentation. Selenium screenshot documentation.
Capture with CDP
CDP returns base64-encoded image data. The parameters and the mechanism for sending a command depend on the Chrome protocol version and client library, so there is no single client-independent command line for invoking it. Use the CDP client available in your automation setup, send Page.captureScreenshot with the options you need, then base64-decode the returned data value and write the bytes to a file. CDP Page.captureScreenshot.
Rank #3
format: choose PNG, JPEG, or WebP.quality: set JPEG quality when using JPEG output.clip: specify a rectangle to capture a region.captureBeyondViewport: request capture beyond the viewport; the current protocol docs give it a default of false.
Because CDP is Chrome-specific and protocol support can vary, verify the command and options against the Chrome version and client you run. The current tot documentation is mutable, while the linked Chromium v136 definition is a version-specific snapshot, not a compatibility matrix.
Full-page screenshots: validate the page, not just the flag
Selenium’s standard screenshot command is defined around the visual viewport, so it does not by itself promise a full-document image. CDP provides captureBeyondViewport, but the existence of that option is not a guarantee that toggling it produces a correct full-page capture for every layout or browser version. W3C WebDriver specification, screen capture; CDP Page.captureScreenshot.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute- Inspect the output dimensions and confirm the bottom of the page is present.
- Test lazy-loaded images and content that appears only after scrolling or interaction.
- Check sticky or fixed headers and other elements that may behave differently in a tall capture.
- Repeat the check at the actual viewport, browser version, and protocol pairing used in your test environment.
These checks matter because capture scope and protocol options do not establish how a specific dynamically rendered page will appear in the resulting image.
Rank #4
- Used Book in Good Condition
Or skip the browser setup
If your goal is a screenshot of a public web page rather than browser-driven test evidence, ScreenshotNeo takes a screenshot or PDF with one GET request. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also has an MCP server for AI agents, and includes 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000.
cURL example (see the ScreenshotNeo API documentation):
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 1,000 free screenshots a month, with no card required.
Recommended Free Tools
Troubleshooting
The image shows only part of the page
The standard WebDriver screenshot covers the visual viewport, not automatically the full document. For a full-page requirement, use a supported alternative or CDP’s beyond-viewport option and check the result on the target page.
Best Value
The CDP command or parameter is rejected
Check the Chrome version, protocol version, and client library together. CDP is Chrome-specific, the tot protocol reference changes, and the Chromium v136 definition marks captureBeyondViewport experimental. An option shown in one protocol snapshot may not be supported identically in another pairing.
The saved file is missing or cannot be opened
For Selenium, check that the process can write to the destination path and that the screenshot call returned successfully before the driver is closed. For CDP, confirm that you base64-decode the response’s image data before writing bytes; saving the base64 text as though it were image bytes will not produce a normal image file.
The full-page image omits or duplicates dynamic content
Check whether the page loads content lazily, uses sticky or fixed elements, or changes layout after scrolling. Compare the output against the actual page under the same viewport and browser version; neither a viewport screenshot nor the CDP option alone establishes correct handling for every dynamic page.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Frequently Asked Questions
Can I use CDP screenshots with a browser other than Chrome?
CDP is Chrome’s protocol, so it is not the portable choice for a multi-browser WebDriver workflow. The WebDriver screenshot command is the standard starting point for that use case.
Does Selenium’s element screenshot capture the whole element, even if it is taller than the viewport?
The WebDriver specification describes the element screenshot as the visible region of its bounding rectangle after the element has been scrolled into view; do not assume it captures every offscreen part.
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.




