In Python, use Selenium WebDriver to open the page and call driver.save_screenshot("page.png"). That captures the browser’s current window as a PNG—not automatically the entire page. For reliable documentation, set the intended viewport, wait for the content you need, save to an explicit path, and choose the right capture scope.
Capture a webpage with Selenium in Python
Install Selenium and have a compatible browser and WebDriver available. Selenium 4 includes Selenium Manager to help manage drivers, but browser and driver availability still depend on your environment. This example creates an output directory, saves the screenshot, checks Selenium’s return value, and closes the browser even if navigation or capture fails:
from pathlib import Path
from selenium import webdriver
output = Path("artifacts/page.png").resolve()
output.parent.mkdir(parents=True, exist_ok=True)
driver = webdriver.Chrome()
try:
driver.get("https://example.com")
# Wait for the page-specific content your documentation requires.
saved = driver.save_screenshot(str(output))
if not saved:
raise OSError(f"Could not save screenshot to {output}")
finally:
driver.quit()
The Selenium Python API describes save_screenshot as saving the current window to a PNG image. It recommends a full path and a filename ending in .png; its documented return value is False on an I/O error. See the Selenium Python WebDriver API, version 4.50.0.
Choose what the screenshot should contain
Decide whether the documentation needs the visible browser window, a single component, or the full long page. These are different capture scopes, and the available API can depend on the browser and language binding.
Recommended Free Tools
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
| Documentation need | Selenium route | Important distinction |
|---|---|---|
| Visible window or viewport | driver.save_screenshot("page.png") |
Saves the current window as a PNG. |
| One component | element.screenshot("element.png") |
Locate the element first; the output focuses on that element. |
| Entire long document | driver.save_full_page_screenshot("page.png") |
The documented full-page method is in Selenium’s Firefox Python API; do not assume it is a portable cross-browser default. |
Selenium’s Working with windows and tabs documentation includes an element screenshot example. Full-document capture is documented separately in the Firefox WebDriver API. The Python WebDriver API also documents screenshot bytes and Base64 output if your workflow needs data rather than a PNG file.
Make captures consistent and ready for documentation
Set the viewport before navigation or capture
Viewport dimensions affect responsive layouts and therefore which content appears. Set the browser window to the size your documentation requires before capturing. Selenium’s Python API exposes window sizing and geometry methods; confirm the actual dimensions in your environment if exact output size matters.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Wait for the page-specific state
A completed navigation does not guarantee that client-rendered text, images, or other asynchronously loaded content is ready. Use an explicit wait for the element or condition your documentation depends on rather than relying on an arbitrary pause. Selenium exposes page-load timeouts, but a timeout limit is not proof that a particular page’s desired content has finished rendering.
Save and verify the artifact
- Create the destination directory before saving and use an explicit path. Resolving the path, as in the example, makes it easier to find the output when a script runs from a different working directory.
- Check the boolean returned by
save_screenshot; treatFalseas a failed save. - Inspect the resulting image for the expected content, dimensions, and capture scope. Selenium documents the capture methods, not a guarantee that a page will render exactly as intended.
Close the browser on every path
Use try/finally and call driver.quit() so the browser is shut down after success or failure. In a test suite, use the framework’s teardown mechanism for the same reason.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Use Chrome Headless when Selenium is not required
For a simple one-off Chrome capture, Chrome’s command-line interface can save a screenshot without a Selenium script:
chrome --headless --screenshot --window-size=412,892 https://example.com
The documented example writes screenshot.png in the current working directory; --window-size controls the capture dimensions. Chrome also documents a --timeout maximum capture delay for screenshots, DOM dumps, and PDFs. That delay is a control, not a guarantee that a site-specific element is ready. See the Chrome Headless command-line reference. This is a direct Chrome CLI route, not Selenium WebDriver code.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Troubleshoot common screenshot problems
- No PNG appears: confirm the parent directory exists, the process can write to it, and the path is the one you expect. Check the boolean result from
save_screenshot. - The image shows the wrong layout: set the intended window dimensions before capture; a different viewport can trigger a different responsive layout.
- Text or images are missing: wait for a page-specific condition that represents readiness of the content you need. Navigation completion alone may be too early.
- The screenshot cuts off the lower page:
save_screenshotcaptures the current window. Use a full-page method only where the browser and binding document support it; the cited Selenium full-page API is Firefox-specific. - The element shot is empty or not the intended component: verify the locator identifies the correct element and that it is present and ready before calling its screenshot method.
- The browser process remains after an error: ensure
driver.quit()runs from afinallyblock or test teardown.
Or skip the browser setup
ScreenshotNeo offers a one-call screenshot API; see the ScreenshotNeo API documentation for its request options. Example cURL request:
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 consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides 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.
Sign up for ScreenshotNeo’s free plan to start with 1,000 screenshots a month and no card.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Frequently Asked Questions
Can Selenium save a screenshot as JPEG or WebP with save_screenshot?
The documented Selenium Python method saves a PNG. Convert the resulting image separately if your documentation pipeline needs another format.
Can I capture a screenshot as bytes instead of writing a file?
Yes. Selenium’s Python WebDriver API documents screenshot bytes and Base64 output methods in addition to saving a PNG file.
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.

