To capture a website screenshot in a serverless function, package a compatible Chrome and ChromeDriver, launch Chrome with Selenium’s --headless option, navigate to the page, wait for the content you need, set the viewport, and save or upload the image before the invocation ends. On AWS Lambda, put Chrome’s writable profile and cache files in /tmp; pin browser and driver versions together and validate the package in the actual cloud runtime.
What the serverless screenshot flow does
Selenium controls a real Chrome browser session without opening a visible desktop window. Chrome for Developers describes headless mode as running “in an unattended environment, without any visible UI.” Since Chrome 112, headless and headful modes share the main Chrome implementation. Starting with Chrome 132.0.6793.0, the older headless implementation became a separate chrome-headless-shell binary; do not assume legacy headless-shell instructions apply to standard Chrome. Chrome headless documentation
The core sequence is the same across function providers: package a compatible browser and driver, launch Chrome with headless options, set writable scratch paths, open a URL, wait for application-specific readiness, set the viewport, capture the screenshot, and persist or return it. A successful Selenium navigation does not by itself guarantee that client-rendered content, images, or fonts are ready.
Choose the function platform and deployment format
AWS Lambda
Lambda works for request-triggered or bounded jobs when the browser package and workload fit the function’s deployment and resource limits. AWS’s current documentation lists a maximum standard invocation of 900 seconds (15 minutes), memory from 128 MB through 10,240 MB, an unzipped ZIP package ceiling of 250 MB including layers, and a 10 GB uncompressed container-image ceiling. These are platform limits, not assurances that a given Chrome build or workload will fit. Lambda allocates CPU in proportion to configured memory, so a low-memory configuration can also make browser startup and page rendering slower. AWS Lambda quotas
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.
Lambda provides temporary storage at /tmp, configurable from 512 MB to 10,240 MB in 1-MB increments. AWS says the data is encrypted at rest with an AWS-managed key. Choose an allocation based on the browser binary, profile/cache files, and concurrent or sequential screenshot workload; remove unnecessary temporary files when appropriate. Treat /tmp as temporary and specific to an execution environment, not as durable artifact storage. AWS Lambda ephemeral storage
Cloud Run and scheduled monitoring
Google Cloud Run documents installing Chromium in a container and names website screenshots as a headless-browser use case. Its guide discusses Puppeteer, Playwright, and Chrome DevTools Protocol rather than giving a Selenium recipe, so validate Selenium and Chrome behavior in the particular container image you choose. Cloud Run can be a better fit when you want to control a browser container without squeezing it into a ZIP-oriented deployment. Cloud Run browser automation
For recurring synthetic monitoring rather than an on-demand screenshot endpoint, AWS CloudWatch Synthetics provides managed canaries using Selenium WebDriver and Chrome in Node.js or Python, with screenshot artifacts and schedules as frequent as once per minute. AWS documents that Selenium canaries support Chrome only. CloudWatch Synthetics canaries
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.
Package compatible Chrome and ChromeDriver
- Select the runtime and packaging approach. For Lambda, deploy Chrome and ChromeDriver in a container image, layer, or compatible deployment artifact. Confirm that the chosen browser binary and its Linux dependencies work in the target runtime.
- Pin browser and driver together. Keep Chrome and ChromeDriver versions aligned with the packaged browser binary. Update and test them as a pair rather than relying on whatever version happens to be installed locally.
- Configure the browser binary explicitly when needed. Set Selenium’s Chrome binary location if it is not discoverable at the default path in the deployment.
- Use writable temporary paths. Direct Chrome’s profile and cache to a writable location such as
/tmpon Lambda. Verify any command-line flags against the Chrome build you actually deploy instead of carrying old flags forward unquestioned. - Test in the cloud runtime. Local Chrome can differ from the deployed Linux image in dependencies, permissions, fonts, and available memory. Run an end-to-end test in the actual runtime before relying on the capture.
Older AWS examples can help illustrate packaging and artifact-storage concepts, but not current version choices: one historical post used Chrome 60 with ChromeDriver 2.33, while another used Python 3.6. Their browser versions, flags, runtime settings, and dependencies should not be copied as current defaults. AWS Lambda Selenium example AWS Startups Selenium tutorial
Capture a screenshot with Selenium in Python
The following handler shows the Selenium flow for an AWS Lambda-style Python deployment. It assumes Selenium and a compatible Chrome/ChromeDriver build are already included in the deployment, and that Chrome is available at the configured path. Set CHROME_BINARY and CHROMEDRIVER_PATH to match your package. The example waits for the document body, sets a viewport, writes a PNG under /tmp, and returns the image bytes as base64 so an API Gateway-style caller can receive them. Adapt the response format to your invocation system.
import base64
import os
import tempfile
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
def lambda_handler(event, context):
url = event["url"]
chrome_binary = os.environ.get("CHROME_BINARY", "/opt/chrome/chrome")
chromedriver_path = os.environ.get("CHROMEDRIVER_PATH", "/opt/chromedriver")
options = webdriver.ChromeOptions()
options.binary_location = chrome_binary
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1440,1000")
options.add_argument(f"--user-data-dir={tempfile.mkdtemp(dir='/tmp')}")
options.add_argument(f"--disk-cache-dir={tempfile.mkdtemp(dir='/tmp')}")
driver = None
try:
driver = webdriver.Chrome(
service=Service(chromedriver_path),
options=options,
)
driver.set_page_load_timeout(45)
driver.get(url)
# Replace this with an application-specific readiness condition
# when the page renders important content after initial navigation.
WebDriverWait(driver, 20).until(
lambda browser: browser.execute_script(
"return document.readyState"
) in ("interactive", "complete")
)
driver.set_window_size(1440, 1000)
screenshot_path = "/tmp/screenshot.png"
if not driver.save_screenshot(screenshot_path):
raise RuntimeError("Chrome did not save the screenshot")
with open(screenshot_path, "rb") as image_file:
encoded = base64.b64encode(image_file.read()).decode("ascii")
return {
"statusCode": 200,
"headers": {"Content-Type": "application/json"},
"body": '{"image_base64":"' + encoded + '"}',
"isBase64Encoded": False,
}
finally:
if driver is not None:
driver.quit()
The sample’s --no-sandbox and --disable-dev-shm-usage options are deployment-dependent, not universal requirements. Check the security model and Chrome behavior in the target image before using them. For an API Gateway binary response, configure binary media types and return the base64 body with the appropriate response encoding; alternatively upload the file to object storage and return a reference. Avoid returning very large base64 images through an invocation response.
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.
Wait for the page you actually need
document.readyState only describes document loading state. A modern site may fetch data or reveal content after it becomes interactive. Prefer waiting for a known selector or application readiness marker when possible:
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.CSS_SELECTOR, "main article"))
)
Use a bounded timeout and handle the case where the selector never appears. A fixed sleep can waste invocation time on fast pages and still be too short for slow ones. Chrome’s command-line --timeout is a CLI capture option; it does not configure Selenium’s wait strategy. Chrome headless command-line options
Viewport, full-page capture, and output persistence
Viewport screenshots
driver.save_screenshot() captures the current browser viewport. Set the viewport before capture with Chrome’s window-size option or Selenium’s set_window_size(width, height); the screenshot dimensions are in CSS pixels unless a device scale factor or other browser configuration changes the output. Chrome’s CLI documentation likewise distinguishes setting --window-size from issuing a screenshot command. Chrome headless documentation
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
Full-page screenshots
Do not treat viewport capture as full-page capture. Selenium’s basic screenshot method does not establish a portable full-page API, and the cited Chrome CLI documentation does not define one either. If the task requires a full page, choose and validate a specific Chrome/Selenium technique for your pinned browser version, including pages with lazy-loaded images and sticky elements. One possible application-specific method is to scroll in increments while allowing lazy content to load, then compose captures, but that is not equivalent to a guaranteed browser-native full-page image.
Persist artifacts beyond the invocation
Save locally only for work that finishes within the invocation, then upload the image to durable object storage or return it to the caller. Files in Lambda’s /tmp are scratch data; they are not an artifact-delivery mechanism. Use a unique object key or run-specific prefix if multiple invocations may write screenshots concurrently. A historical AWS Lambda example used an S3 prefix for screenshot output, which illustrates the pattern but is not a current service requirement. Historical AWS S3 screenshot example
Operational limits, reliability, and cost
- Cold starts and browser startup: a function must initialize a large browser package and launch Chrome; measure end-to-end latency in the deployed environment rather than assuming a local run predicts it.
- Memory and CPU: browser rendering can consume substantial resources, and Lambda CPU scales with configured memory. Test the hardest page and expected concurrency at the intended memory setting.
- Timeouts: set Selenium navigation and explicit-wait timeouts below the function’s total timeout so code can clean up or return a controlled failure. Lambda’s maximum standard invocation duration is 900 seconds, but a screenshot endpoint generally needs a much shorter application-level deadline. AWS Lambda quotas
- Scratch storage: allocate enough
/tmpfor the browser profile, cache, and image output, while accounting for repeated captures in a warm execution environment. AWS Lambda ephemeral storage - External-site variability: DNS, TLS, rate limits, consent banners, bot challenges, and slow third-party resources can all affect output. Treat a blank or challenge page as a failed capture if it is not the intended result.
- Cost: the platform documents quotas, but the material here does not establish a cost winner between Lambda, Cloud Run, and managed monitoring. Compare the actual provider’s current compute, storage, request, and network charges for your workload.
Troubleshooting common failures
- ChromeDriver cannot start or reports a session-creation error: confirm Chrome and ChromeDriver correspond to the packaged browser, check executable permissions and binary paths, and verify that required Linux libraries exist in the deployment image.
- Chrome exits immediately in Lambda: confirm profile and cache directories are writable and point to temporary storage. Inspect the function logs for the underlying Chrome error; do not blindly add legacy flags copied from old tutorials.
- Navigation times out: set a bounded page-load timeout, inspect network and DNS reachability from the function, and wait for the particular element needed rather than requiring every resource to finish indefinitely.
- Screenshot is blank or missing expected content: wait for an application-specific selector or readiness marker, then check whether the URL redirected, returned an error, displayed a consent layer, or served a bot challenge.
- Image is clipped: confirm whether the desired result is the viewport or entire document. Increase the viewport for a taller visible region; implement and validate a full-page strategy separately.
- Function runs out of memory, disk, or time: test with realistic pages and concurrency, increase the appropriate Lambda memory or ephemeral storage within documented limits, reduce unnecessary resources, or move the workload to a container-oriented service.
- Screenshot disappears after the invocation: upload it to durable storage before returning.
/tmpis temporary and execution-environment-specific.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. A single GET request returns a PNG, JPEG, WebP, or PDF. The cURL request below captures a target page as WebP; create an API key and replace the URL with the page you need. See the ScreenshotNeo API documentation for request options and response details.
Free tools Windows power users keep installed
One-click scans. No signup required.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server gives Claude, Cursor, and other MCP clients the tools take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo free: 1,000 screenshots a month, no card required.
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’s basic screenshot method capture a full webpage?
No. The basic WebDriver screenshot captures the current viewport; full-page capture requires a separate technique that you validate for your Chrome version and page behavior.
Is CloudWatch Synthetics suitable for a scheduled Selenium screenshot?
Yes. AWS documents Selenium-and-Chrome canaries in Python and Node.js, with screenshot artifacts and schedules as frequent as once per minute.
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 →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.




