Crashes, 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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor a dependable Python Selenium deployment on AWS Lambda, package Selenium, a Linux-compatible browser, its matching ChromeDriver, and the required libraries in a Lambda-compatible container image. Choose the Lambda Python runtime and CPU architecture first, then build and test the browser stack for that exact combination. AWS Python 3.12-and-later base images use Amazon Linux 2023 (AL2023); Python 3.11 uses Amazon Linux 2 (AL2), so package installation instructions are not interchangeable.
This guide uses an AWS Python base image and browser binaries that you obtain and verify separately. The available documentation establishes the Lambda image workflow, but not a current Chrome-for-Testing download URL or a universal Chrome/ChromeDriver version pair. Rather than risk a misleading copy-and-paste download command, the build below requires you to supply verified browser files.
Choose the Lambda runtime, image, and architecture
Start with the runtime configured for the function. AWS maps Python 3.12 and later Lambda base images to AL2023, while Python 3.11 uses AL2. AL2023 minimal images use microdnf, also available through the dnf symlink, rather than AL2’s yum. The operating-system version also affects available libraries, including glibc. See AWS’s Python Lambda container-image guide and AL2023 Lambda guidance.
AWS describes three image paths: an AWS language base image, an AWS OS-only image, or a non-AWS base image. The language image includes the runtime and Lambda Runtime Interface Client (RIC). With an OS-only or other base image, AWS directs you to include the language runtime interface client so Lambda can invoke the application. For a first Selenium deployment, the AWS Python language image usually avoids extra runtime integration work.
#1 Best Overall
Choose the Lambda CPU architecture—typically x86_64 or arm64—before sourcing the browser files. Build the container for the corresponding Docker platform, linux/amd64 or linux/arm64, and ensure both browser and driver binaries support it. AWS documents platform-specific builds in its container image instructions.
Prepare a matching browser and driver
ChromeDriver must be compatible with the Chrome or Chromium build you package. Resolve both from a current, authoritative release source at build time; verify the selected release and architecture instead of copying binaries from a workstation or hard-coding an unverified version. The code below expects the verified files in a local browser/ directory:
browser/chrome: the Linux browser executable.browser/chromedriver: the Linux driver executable compatible with that browser.- Any additional shared libraries required by those particular binaries.
Make both executables runnable before building, for example with chmod +x browser/chrome browser/chromedriver. This does not install missing libraries: if the browser exits with a shared-library error, identify the missing library for the chosen binary and add the appropriate package for the image’s operating-system release. Avoid assuming an AL2 package name or library list applies unchanged to AL2023.
A ZIP deployment may work for appropriately sized dependency bundles, but AWS’s general Lambda documentation does not establish one universal ZIP procedure, size allowance, or compatibility recipe for a full Chrome stack. A container is a practical way to package the browser, driver, and native dependencies together; it is not a claim that ZIP is impossible.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #2
Create the Selenium handler and container
Python handler
Save this as app.py. It starts a headless browser, navigates to a URL supplied in the Lambda event, and returns the page title and final URL. The browser and driver paths match the files copied by the Dockerfile below.
import json
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
def handler(event, context):
url = event.get("url", "https://example.com")
options = webdriver.ChromeOptions()
options.binary_location = "/opt/browser/chrome"
options.add_argument("--headless=new")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1440,1000")
options.add_argument("--user-data-dir=/tmp/selenium-profile")
driver = webdriver.Chrome(
service=Service("/opt/browser/chromedriver"),
options=options,
)
try:
driver.set_page_load_timeout(45)
driver.get(url)
return {
"statusCode": 200,
"headers": {"content-type": "application/json"},
"body": json.dumps({"title": driver.title, "url": driver.current_url}),
}
finally:
driver.quit()
Lambda’s writable temporary directory is /tmp; the example puts the browser profile there instead of relying on a writable application directory. Tune the page-load timeout to the pages your function is expected to handle. A timeout is not proof that the page or browser is broken: investigate navigation behavior and the function’s execution limit, and ensure driver.quit() runs on errors as well as success.
Requirements and Dockerfile
Save a pinned Selenium dependency in requirements.txt, for example selenium==<version-you-validated>, replacing the angle-bracket text with the exact version tested by your application before building. Do not deploy that literal placeholder. Pinning makes the Python dependency deliberate; it does not select a compatible browser/driver pair.
Save this as Dockerfile. Select the AWS Python base image tag to match your Lambda runtime. For Python 3.12, the example uses the AWS Python 3.12 image; use the corresponding supported tag when selecting another runtime.
FROM public.ecr.aws/lambda/python:3.12
COPY requirements.txt ${LAMBDA_TASK_ROOT}/requirements.txt
RUN pip install --no-cache-dir -r ${LAMBDA_TASK_ROOT}/requirements.txt
COPY app.py ${LAMBDA_TASK_ROOT}/app.py
COPY browser/ /opt/browser/
RUN chmod +x /opt/browser/chrome /opt/browser/chromedriver
CMD ["app.handler"]
This minimal example does not install arbitrary browser libraries because the required package set depends on the browser build and the selected Amazon Linux image. Add the verified native packages using that image’s package manager—AL2023’s dnf/microdnf or AL2’s applicable package tooling—and rebuild. If using a non-AWS base image rather than the AWS language image, follow AWS’s RIC instructions and include awslambdaric.
Build for Lambda and test an actual browser launch
- Build for the selected CPU. For an x86_64 Lambda function, run
docker buildx build --platform linux/amd64 --provenance=false -t selenium-lambda .. For an arm64 function, use--platform linux/arm64and provide arm64 browser and driver files. AWS’s Lambda image documentation explains platform selection and image requirements. - Start the image locally. Run
docker run --rm -p 9000:8080 selenium-lambda. The AWS Lambda base image supports the local invocation flow documented by AWS. - Invoke the handler with a controlled page. In another terminal, run
curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"url":"https://example.com"}'. A successful browser smoke test returns JSON containing the title and final URL. An import-only check does not verify that Chrome can launch. - Repeat on the target architecture. A successful amd64 local run does not validate arm64 artifacts. Test the image that corresponds to the Lambda function’s configured architecture.
AWS’s Python image guide covers local testing and invocation. Also deploy to a non-production Lambda function to check the actual runtime, permissions, outbound network access, configured memory and timeout, and browser startup behavior.
Handle Selenium Manager deliberately
Modern Selenium bindings include Selenium Manager, which can manage a missing driver; Selenium’s Selenium Manager documentation and Python API documentation describe that behavior. It can simplify local setup, but its presence does not guarantee that a Lambda invocation can download browser or driver files. Network access, download availability, writable cache location, binary libraries, and cold-start behavior all need validation in the deployed configuration.
For repeatable deployments, package the intended browser and matching driver in the image, as above. If you choose to rely on Manager downloads, test its cache and network behavior in the actual Lambda environment and account for cases where a new execution environment has no cached binaries.
Troubleshoot common failures
- “Unable to obtain driver” or driver startup failure: Check that
/opt/browser/chromedriverexists, is executable, and matches the browser version and architecture. Confirm the Selenium configuration points to that file rather than assuming a local driver path transfers to Lambda. - Browser reports a missing shared library: The browser’s native dependencies are not all present in the image. Identify the missing library for the selected browser artifact, install the corresponding package for AL2 or AL2023, then rebuild and rerun the local invocation.
- “Exec format error” or an immediate process exit: The browser or driver may target a different CPU architecture than the image. Match Docker’s platform, Lambda’s configured architecture, and both executable formats.
- Browser cannot write a profile or temporary files: Put profile and runtime data under a writable location such as
/tmp; make the profile path unique if concurrent browser instances share a container. - Works locally but fails in Lambda: Compare the deployed function’s architecture and image with the locally tested image. Check logs for browser stderr, missing libraries, permissions, outbound access, and Lambda timeout or memory constraints; run a real navigation test rather than only importing Selenium.
- Selenium Manager succeeds on a laptop but not in Lambda: Do not infer that invocation-time downloads are available in Lambda. Package the verified files or explicitly validate network access and cache handling in the deployed setup.
Performance, reliability, and cost considerations
A browser increases image contents and makes startup more involved than a handler that only imports Python modules. The actual image size, startup time, memory use, duration, and Lambda cost depend on your browser build, page, function configuration, and workload; no general Selenium-on-Lambda benchmark or cost figure is established here. Measure those values with your own representative pages and function settings.
Keep the browser and driver versions fixed for a release, and rebuild deliberately when updating either. That makes failures easier to reproduce than silently resolving a driver at invocation time. Treat browser navigation as untrusted external I/O: set timeouts, handle navigation errors, always close the driver, and avoid allowing an event to direct the function to arbitrary internal or sensitive endpoints.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your task is to capture a page as an image or PDF rather than automate a browser session, ScreenshotNeo offers a screenshot API and MCP server. A single GET request returns a PNG, JPEG, WebP, or PDF; it is not a substitute for Selenium when you need browser interaction, custom application logic, or to inspect a live browser session.
For example, this cURL request saves a WebP screenshot of Stripe. See the ScreenshotNeo API documentation for request options.
Best Value
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 before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; 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 provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.
Sign up free for 1,000 screenshots a month, with no card required.
Frequently Asked Questions
Can I use Selenium Manager instead of packaging ChromeDriver?
Yes, if you validate its download, cache, and network behavior in the Lambda configuration you will deploy. For predictable, repeatable launches, this guide packages the browser and driver.
Does the example Dockerfile install Chrome?
No. It copies browser and driver files you have independently obtained and verified; the source material does not establish a current authoritative download URL or universal compatible release pair.
Recommended Free Tools
Can I use a ZIP deployment instead of a container?
Possibly, for a suitable bundle, but the AWS material cited here does not establish a universal ZIP recipe or browser compatibility guarantee for a full Chrome stack.
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.

