Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To capture a website screenshot with Selenium in a serverless function, package a compatible Chrome browser and ChromeDriver, start Chrome with --headless, send the page request through WebDriver, wait for the content you need, set the viewport, and save or upload the screenshot before the invocation ends. For AWS Lambda, give Chrome writable temporary storage such as /tmp, and test the packaged browser in the actual Lambda runtime; local success alone does not establish cloud compatibility.

Build a minimal Selenium capture

The Python example below shows the core flow: configure Chrome, navigate, wait for a meaningful page condition, size the viewport, and save a viewport screenshot. It assumes Selenium, Chrome, and a compatible ChromeDriver are already available in the runtime. The Chrome binary path and driver setup are deployment-specific, so configure them for the exact artifacts you package.

Python example

import os
from pathlib import Path

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

URL = "https://example.com"
OUTPUT = "/tmp/page.png"

options = Options()
options.add_argument("--headless")
options.add_argument("--window-size=1440,1000")
options.add_argument("--user-data-dir=/tmp/chrome-profile")
options.add_argument("--disk-cache-dir=/tmp/chrome-cache")
# Set this when Chrome is not installed at its default location:
# options.binary_location = "/opt/chrome/chrome"

driver = webdriver.Chrome(options=options)
try:
    driver.set_page_load_timeout(60)
    driver.get(URL)
    WebDriverWait(driver, 30).until(
        EC.presence_of_element_located((By.TAG_NAME, "body"))
    )
    # Replace the body check with an application-specific ready marker
    # when the page renders important content after initial navigation.
    Path(OUTPUT).parent.mkdir(parents=True, exist_ok=True)
    if not driver.save_screenshot(OUTPUT):
        raise RuntimeError("Chrome did not save the screenshot")
finally:
    driver.quit()

print(OUTPUT)

This captures the current viewport, not a guaranteed full-page image. Change the URL, viewport dimensions, readiness condition, and output location to suit the workload. For a production endpoint, return the image bytes or upload the file to durable object storage before the function returns.

Package browser and driver together

Install or package a Chrome binary and a ChromeDriver compatible with that binary. Pin and update them as a pair. Chrome’s documented Selenium headless mode uses --headless; since Chrome 112, headless and headful modes share the main Chrome implementation. The old headless implementation became a separate chrome-headless-shell binary starting with Chrome 132.0.6793.0, so instructions that refer to the older implementation may not match a current Chrome package. See Chrome for Developers’ headless mode documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

If Chrome is installed somewhere other than its default path, set options.binary_location. Direct its profile and cache to writable scratch storage. Older Lambda examples use /tmp, but validate flags against the modern Chrome build you selected rather than copying legacy flags wholesale.

Choose a readiness condition and capture scope

Wait for the page content you need

A successful navigation does not necessarily mean the page is visually ready. Use an explicit Selenium wait for an element or application-specific marker that indicates the relevant content has appeared. If a page depends on client-side rendering, waiting only for the document body may be insufficient. Keep waits bounded, and handle navigation timeouts and missing elements as capture failures rather than relying on one fixed sleep for every site.

Chrome’s command-line --timeout option applies to the command-line screenshot workflow; it does not define a Selenium readiness strategy. Selenium code should set its own page-load timeout and use explicit waits appropriate to the target page. Chrome’s command-line documentation also describes --screenshot and --window-size, but those CLI flags are not Selenium API calls. See the Chrome headless command-line documentation.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Set viewport before saving

Set the window size before capture so the page lays out at the intended viewport. A standard Selenium save_screenshot call captures the visible browser viewport; do not assume it creates a full-page image. If you need full-page output, select a Chrome/Selenium technique for that purpose and validate it against the exact browser version and page behavior you deploy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Deploy the capture in AWS Lambda

For Lambda, use a deployment artifact, layer, or container image that contains compatible browser components and any required runtime dependencies. Browser startup consumes CPU and memory, and Lambda allocates CPU in proportion to configured memory. The platform limits documented by AWS are ceilings, not a promise that a particular Chrome build will fit or run at a particular setting. AWS’s quota documentation, accessed October 3, 2026, lists these standard limits:

Lambda setting or package Documented limit
Maximum standard invocation duration 900 seconds (15 minutes)
Function memory 128 MB to 10,240 MB
ZIP package contents, unzipped, including layers Up to 250 MB
Container image package, uncompressed Up to 10 GB

These are AWS platform quotas, not recommended Chrome settings. Choose memory, timeout, package format, and output handling based on the browser binary, dependencies, page weight, and capture volume. Consult AWS Lambda quotas for current limits.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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 writable temporary storage

Chrome needs writable space for its profile and cache. Lambda’s /tmp directory is unique to an execution environment and is temporary, so it is suitable for browser working files but not a durable screenshot archive. AWS documents configurable ephemeral storage from 512 MB to 10,240 MB, adjustable in 1-MB increments; data is encrypted at rest with an AWS-managed key. Allocate space for the browser’s working files as well as the image and any concurrent activity. See AWS Lambda ephemeral storage.

Persist the screenshot before returning

Save to /tmp during capture, then return the image through your invocation’s response mechanism or upload it to object storage if it must outlive the execution environment. A historical AWS Lambda Selenium example stores screenshots in S3 under a run-specific prefix, illustrating the persistence pattern rather than requiring a particular storage service. Its Chrome 60, ChromeDriver 2.33, and Java 8 setup is dated and should not be copied as current configuration. See the historical AWS Lambda Selenium example.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test, troubleshoot, and tune the function

Common failures and fixes

  • ChromeDriver cannot start Chrome or reports a session-creation error: check that the driver matches the packaged Chrome binary and that the configured binary path is correct. Update and pin both artifacts together.
  • Chrome exits immediately or reports an unwritable profile: direct profile and cache paths to writable temporary storage, such as Lambda’s /tmp, and confirm the function has sufficient temporary storage configured.
  • The screenshot is blank or misses dynamic content: replace a generic body wait with a wait for the actual content or readiness marker. Check whether the page needs more time after navigation, while keeping the wait bounded.
  • The function times out: separate browser startup, navigation, readiness waiting, and upload time when diagnosing the invocation. Reduce unnecessary work or increase the configured timeout within the platform limit; do not treat the maximum timeout as a target.
  • The screenshot is cropped: confirm the requested viewport and remember that the basic Selenium screenshot call captures the visible viewport. Use and test a full-page capture technique if the full document is required.
  • The browser works locally but fails in Lambda: validate the packaged artifact, Linux dependencies, writable paths, memory, and startup behavior in the actual cloud runtime. Local and cloud environments differ.

Performance and reliability choices

Browser launches and page loads are workload-dependent; no single memory size, wait duration, or storage allocation is reliable for every site. Measure representative pages in the deployed runtime, including slow or script-heavy pages, and set explicit upper bounds for navigation and readiness. Keep screenshots out of ephemeral storage when they need durable retention, and define how failed captures and uploads are reported to the caller.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

Older AWS tutorials can help explain packaging concepts, but their concrete versions and settings are historical: one uses Chrome 60 and ChromeDriver 2.33, and another uses Python 3.6. Treat them as illustrations, not current deployment recipes. See the AWS Startups Lambda Chromium tutorial.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When Lambda is not the right fit

Cloud Run for a container-based workflow

Google Cloud documents installing Chromium in a container and lists web-page screenshots as a headless-browser use case. Its guidance names Puppeteer, Playwright, and Chrome DevTools Protocol, not a Selenium recipe; Selenium-specific behavior therefore needs validation in the selected image. Cloud Run is worth considering when container-based browser packaging better suits the workflow. See Google Cloud Run browser automation documentation, updated September 30, 2026.

CloudWatch Synthetics for recurring monitoring

For scheduled synthetic monitoring rather than a custom on-demand screenshot endpoint, AWS CloudWatch Synthetics supports Node.js and Python canaries using Selenium WebDriver and Chrome, saves screenshot artifacts, and supports schedules as frequent as once per minute. AWS documents Chrome as the supported browser for Selenium canaries. This is a managed canary workflow; choose it when monitoring is the goal and its workflow fits, rather than assuming it replaces arbitrary Lambda application logic. See AWS CloudWatch Synthetics canaries.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

The available platform documentation establishes capabilities and limits, not a cost winner between Lambda, Cloud Run, and Synthetics. Compare packaging and browser-update responsibility, invocation pattern, runtime envelope, and how artifacts are delivered for your use case.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. Make a GET request with the page URL and save the returned image. This cURL example uses the API’s documented endpoint and parameters; see the ScreenshotNeo API documentation for options and response details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Responses identify the page verdict and billing status in headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots a month with no card required; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I use the Chrome command-line –screenshot flag from Selenium?

No. Chrome’s –screenshot flag is a command-line capture option; Selenium captures through WebDriver methods such as save_screenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does Selenium’s basic screenshot method capture an entire page?

No. The example’s save_screenshot call captures the visible viewport. Full-page capture requires a separate technique validated for the Chrome version and page.

Can Lambda /tmp store screenshots permanently?

No. Lambda’s /tmp is temporary and specific to an execution environment; upload screenshots that must persist to durable storage before the invocation ends.

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.