The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
For a Chrome page you own or are authorized to test, use Selenium to call Chrome DevTools Protocol’s Page.captureScreenshot with captureBeyondViewport set to true. Selenium’s regular screenshot method captures the current browsing context; it does not promise a full-document image.
Do not run this workflow against the live IRCTC booking service. IRCTC’s published terms prohibit automation and scripting software. Use a local fixture or approved staging page instead. A screenshot is not a ticket or reservation record.
Why does Selenium only screenshot the visible page?
Selenium’s standard screenshot calls—such as Python’s save_screenshot or the WebDriver screenshot command—are for the current browsing context. They do not, by themselves, promise to expand the image to the full document. For a full-page capture in Chrome, use its DevTools Protocol (CDP) Page.captureScreenshot command and request content beyond the viewport.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChrome’s protocol defines captureBeyondViewport as false by default. The capture response contains image data encoded as Base64, which the example below decodes to a PNG file. See the Selenium screenshot documentation and the Chrome DevTools Protocol Page documentation.
#1 Best Overall
Important: do not automate live IRCTC booking pages
IRCTC’s online booking terms say: “Use of automation software and/or Scripting Software is strictly prohibited.” Keep Selenium captures to pages you own or are expressly authorized to automate, such as a local test fixture or approved staging site. For an actual booking, follow the current IRCTC terms and retain the official booking record; an image of a page is not a reservation or ticket.
In a Ministry of Railways release dated 4 June 2025, the ministry reported deactivating 2.5 crore suspected user IDs, 31,814 tickets booked in one minute on 22 May 2025, and 82.57 lakh average daily logins in FY 2024–25. These are ministry-reported figures for the stated periods, not independent measurements or predictions about an individual account. The terms themselves provide the relevant restriction on automation. See the Press Information Bureau release.
How to capture a full-page screenshot with Selenium in Chrome
This Python example uses Selenium’s Chrome driver interface to request document dimensions, capture beyond the viewport through CDP, and save the returned PNG data. Point it only at an authorized test or staging page.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesRank #2
- Install Selenium and make sure the Chrome and driver versions used by your project support the CDP commands shown here.
- Navigate to the authorized page and wait for the specific application content your test needs. A completed navigation alone may not mean asynchronous content has rendered.
- If the page lazy-loads content as it scrolls, scroll through the relevant area in the test context and wait for that content to appear before measuring and capturing.
- Run the capture and inspect the resulting file, especially its bottom edge and any important text or tables.
import base64
from selenium import webdriver
# Use only for a page you own or are authorized to automate.
driver = webdriver.Chrome()
try:
driver.get("https://example.test/page")
# Replace this with a condition for the application content your test needs.
# driver.implicitly_wait(...) is not a substitute for a page-specific readiness check.
metrics = driver.execute_cdp_cmd("Page.getLayoutMetrics", {})
content = metrics.get("cssContentSize") or metrics.get("contentSize")
if not content:
raise RuntimeError("Chrome did not return document content dimensions")
result = driver.execute_cdp_cmd(
"Page.captureScreenshot",
{
"format": "png",
"captureBeyondViewport": True,
"fromSurface": True,
"clip": {
"x": 0,
"y": 0,
"width": content["width"],
"height": content["height"],
"scale": 1,
},
},
)
with open("full-page.png", "wb") as image_file:
image_file.write(base64.b64decode(result["data"]))
finally:
driver.quit()
The layout metric field names and Selenium’s CDP wrapper can vary between browser and driver releases. Treat this as an implementation pattern: check the versions supported by your project and validate the saved image rather than assuming every release behaves identically. Chrome’s protocol documents Page.getLayoutMetrics and Page.captureScreenshot in the Page domain reference.
Why measure the page before capturing?
The example uses Page.getLayoutMetrics to obtain the document content dimensions, then supplies those dimensions as the capture clip. It prefers cssContentSize and falls back to contentSize for compatibility with differing responses. If Chrome returns neither, it stops with an explicit error instead of silently producing a misleading image.
Why wait for content and handle lazy loading?
A full-document capture only describes the page as it has rendered; it does not guarantee that dynamic, lazy, or interaction-dependent content has loaded. Wait for a page-specific condition, and, where appropriate for your authorized test, scroll through the content that loads on demand before taking the screenshot. Inspect the output to confirm the needed material is present.
Rank #3
Choosing a screenshot method
| Method | What it captures | Useful when | Key consideration |
|---|---|---|---|
| Selenium’s ordinary screenshot call | The current browsing context; full-document expansion is not promised | You need a viewport screenshot in an automated test | Use CDP for a Chrome full-page capture |
Chrome CDP Page.captureScreenshot |
Can extend beyond the viewport with captureBeyondViewport: true |
You need a full-page raster from authorized Selenium-driven Chrome | Check supported browser/driver versions and rendered content |
| Chrome headless screenshot or PDF output | Browser screenshot or PDF output | You need a browser-level capture or a readable document rather than one very tall raster | Chrome documents headless screenshots and PDF output; a full-page screenshot takes more than the basic screenshot flag. See Chrome headless documentation. |
A browser’s manual full-page capture feature does not make automated access to a restricted booking service permissible. Apply the target site’s terms regardless of which capture method you choose.
Troubleshooting full-page Selenium captures
Only the visible area appears
Check that the code invokes Chrome’s CDP Page.captureScreenshot command and sets captureBeyondViewport to true. A normal WebDriver screenshot call is a different operation.
The bottom is missing or content appears blank
Check the dimensions returned by Page.getLayoutMetrics, wait for asynchronous application content, and account for lazy loading. The capture parameter does not force every page component to render.
Rank #4
A sticky header or overlay obscures content
The screenshot records the rendered page state, including sticky headers and overlays. For an authorized test, prepare a suitable fixture or page state before capture. Do not automate a live booking flow in a way that conflicts with IRCTC’s terms.
The image is too tall or unwieldy
Very tall captures can produce large images or run into browser or device limits. Capture logical sections or use PDF output when a single raster is impractical.
The target is a live IRCTC booking page
Do not proceed with Selenium automation: IRCTC’s published terms prohibit automation and scripting software. Use only a capture method permitted by the current terms.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
For a page you are permitted to capture, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. Cookie banners are accepted and removed before the shot, along with supported newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed; the response identifies the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. See ScreenshotNeo and its API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.test/page -o shot.webp
Use this only where you are authorized to capture the target page; an API does not override site terms. Sign up for 1,000 free screenshots a month, with no card required.
Best Value
Frequently Asked Questions
Can I use Selenium’s regular screenshot method for a full webpage?
It is intended for the current browsing context and does not promise a full-document capture; use Chrome CDP for the full-page approach described above.
Does a full-page screenshot include every lazy-loaded element?
No. Wait for the content required by your test, trigger lazy loading where appropriate, and inspect the image.
Does the Selenium example work with every browser?
No. It uses Chrome’s DevTools Protocol through Selenium’s Chrome driver interface; check compatibility with your installed Chrome and driver versions.
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.

