Use Selenium’s Chrome options to add --headless, open the URL, wait for the content your test needs, and call the binding’s screenshot method. In Python, the standard operation saves the current window (the current browsing context) as a PNG. It does not, by itself, prove that an entire long page was captured.
This guide shows a reliable Python workflow, explains timing and dimensions, covers equivalent implementation choices, and diagnoses the failures that commonly appear in unattended Chrome sessions.
Minimal Python example
Install Selenium in the environment that will run the test:
python -m pip install selenium
Then run this complete script:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
try:
driver.get("https://example.com")
driver.save_screenshot("screenshot.png")
finally:
driver.quit()
save_screenshot(filename) writes a PNG of the current window and returns a Boolean result. Use an absolute path when a CI job or another process must find the file:
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
from pathlib import Path
output = Path("artifacts/example.png").resolve()
output.parent.mkdir(parents=True, exist_ok=True)
assert driver.save_screenshot(str(output))
print(output)
The related Python method get_screenshot_as_file(filename) also writes a PNG and returns False for an I/O error. Selenium additionally exposes the image as base64 or raw PNG bytes when you need to upload it instead of creating a file.
What headless Chrome changes
Chrome’s official headless documentation describes headless mode as running Chrome in an unattended environment without visible UI. Selenium still creates a normal WebDriver session; the difference is that Chrome receives the --headless argument through its options.
Chrome’s headless implementation changed in Chrome 112: Chrome creates platform windows but does not display them. The older implementation is available only as the standalone chrome-headless-shell binary from Chrome 132.0.6793.0 onward. If two machines behave differently, record both the Chrome and ChromeDriver versions before changing your test.
Build the driver explicitly
ChromeDriver capabilities are supplied through a ChromeOptions object passed to the driver constructor. The exact constructor and option class names differ between language bindings, but the pattern is the same.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesPython
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
Useful display options
Set a deterministic viewport when layout matters. A larger viewport can change responsive breakpoints and therefore the pixels you capture.
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
options.add_argument("--window-size=1440,900")
Keep options that your environment actually requires separate from screenshot logic. For example, a locked-down container may need an environment-specific sandbox setting; do not copy such flags blindly into local runs because they affect Chrome’s security model.
Wait for the page you intend to capture
driver.get() means navigation completed according to the browser’s navigation strategy. It does not guarantee that a client-side component, lazy image, chart, animation, or API response has finished rendering.
Wait for a condition tied to the evidence in the screenshot. This example waits for a dashboard element to become visible:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 30)
driver.get("https://example.com/dashboard")
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "[data-testid='dashboard']")))
driver.save_screenshot("dashboard.png")
Other page-specific conditions include a status changing from “Loading” to “Ready”, a table containing a required row, or an image’s complete property becoming true. Avoid a universal sleep when a deterministic condition is available. If the page has unavoidable asynchronous work, a short, documented delay can supplement—not replace—a meaningful readiness check.
Capture scope, size, and output
Current window, not an automatic full-page image
The documented Selenium screenshot call captures the current browsing context/current window. The supplied API documentation does not establish a general full-page recipe for the standard call, so do not describe save_screenshot() as a whole-page capture of an arbitrarily long document.
Rank #3
- 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
- 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
- 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
If your requirement is a full-page artifact, define that requirement separately and choose an approach that explicitly supports it. A viewport screenshot may be exactly right for a visual regression test, while a long-page archive needs a different capture design.
Control dimensions
Use --window-size=width,height before creating the driver. Confirm the resulting dimensions in the session when diagnosing responsive-layout differences:
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 →print(driver.get_window_size())
Device-pixel scaling, operating-system display settings, and browser version can all affect the final bitmap. Keep the execution image and browser versions stable for pixel comparisons.
PNG bytes or base64
When a test framework stores artifacts itself, use the binding’s byte or base64 screenshot method instead of writing a temporary file. The Python file method remains the simplest portable example and makes I/O failures visible at the call site.
Always close the session
Put driver.quit() in a finally block. It closes every browser window and the WebDriver service even when navigation, waiting, or file writing fails. Calling only driver.close() can leave the session or service process running.
Rank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
driver = webdriver.Chrome(options=options)
try:
# navigate, wait, and capture
pass
finally:
driver.quit()
Selenium versus Chrome’s direct screenshot command
| Approach | Page interaction | Live WebDriver session | Best fit |
|---|---|---|---|
| Selenium WebDriver screenshot API | Yes: click, scroll, inspect, and wait in code | Required | Existing tests and stateful workflows |
| Chrome headless CLI | No WebDriver interaction; command-line navigation | No | Simple one-off captures |
Chrome’s direct headless CLI can write screenshot.png in the current working directory:
Free tools Windows power users keep installed
One-click scans. No signup required.
chrome --headless --screenshot --window-size=412,892 https://example.com
The CLI also supports --timeout, which sets a maximum wait before capture:
chrome --headless --screenshot --window-size=412,892 --timeout=10000 https://example.com
These are Chrome CLI behaviors, not automatic Selenium WebDriver settings. Use Selenium when the page must be manipulated or inspected before the image is taken; use the CLI when navigation and a fixed delay are sufficient.
Equivalent bindings
Other Selenium bindings expose equivalent screenshot operations, but method names and option syntax vary. Consult the API for your language and keep the same sequence: create options, add --headless, construct Chrome, navigate, wait for a page-specific condition, save the current context, and quit. Do not paste Python method names into Java, JavaScript, C#, or Ruby without checking that binding’s API.
Common failures and fixes
“Unable to obtain driver” or session creation failure
- Cause: Chrome, ChromeDriver, or Selenium cannot be found or versions are incompatible.
- Fix: Verify the browser launches on the same machine, inspect the reported versions, update the Selenium package and driver arrangement, and ensure the executable is available to the service account used by CI.
The file is missing or empty
- Cause: The path is relative to an unexpected working directory, or the process lacks write permission.
- Fix: Resolve an absolute path, create its parent directory, check the Boolean return value, and publish the artifact directory from CI.
The screenshot shows a loading shell
- Cause: The script captured immediately after navigation while JavaScript content was still loading.
- Fix: Wait for the specific element or state that proves readiness; increase the explicit wait timeout only after choosing the right condition.
Different layout or clipped content
- Cause: An implicit default viewport, responsive breakpoint, device scale, or browser-version change.
- Fix: Set
--window-size, record the browser version, and keep the same execution image for comparisons.
It works visibly but not in headless mode
- Cause: Timing, viewport, authentication, permissions, or a site behavior differs without a visible UI.
- Fix: Log the URL and readiness state, capture browser and driver logs, set the viewport explicitly, and wait for observable content rather than relying on a human seeing progress.
Chrome exits in a container
- Cause: Container resource limits or environment-specific Chrome restrictions.
- Fix: Check shared-memory and process limits, use only the flags required by your container policy, and reproduce with the same image locally. Treat security-related flags as a deployment decision, not a generic screenshot fix.
Reliability and cost considerations
Selenium itself does not provide a performance benchmark in the documented material. Capture time depends on startup, navigation, network activity, rendering, waits, and file I/O. Reuse a driver for a sequence of captures when test isolation allows it; create a fresh session when isolation is more important than startup overhead.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- Compatible with Nintendo Switch 2’s new GameChat mode
- HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
- Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
- Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
- Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video
For reproducible visual tests, pin the browser version, viewport, timezone, locale, fonts, and test data. Record failures with the URL, window size, browser version, wait condition, and a diagnostic screenshot or page source where policy permits.
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF, with options for full-page capture, element selectors, device presets, custom viewport and retina scale, waits, custom CSS or JavaScript, cookies and headers, blocking, caching, and async jobs. It removes cookie/consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo documentation for parameters and response headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to 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 screenshots. Create a free ScreenshotNeo account.
Frequently Asked Questions
Does Selenium’s standard screenshot method capture an entire page?
It captures the current browsing context/current window. The standard documented call should not be treated as a guaranteed full-page capture.
Recommended Free Tools
Which headless argument should I pass to Chrome?
Add --headless to ChromeOptions before constructing the WebDriver.
How do I prevent a screenshot from being taken too early?
Wait for a page-specific condition, such as a required element becoming visible or a loading state changing to ready.
When should I use Chrome’s CLI instead of Selenium?
Use the CLI for simple navigation and timed capture; use Selenium when you must interact with or inspect the page before taking the image.
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.

