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 →To capture a website screenshot from Python on AWS Lambda, package Selenium, a compatible Chrome or Chromium browser, its matching WebDriver, and required system libraries in a Linux Lambda container image. The function must launch the browser with Lambda-compatible settings, wait for a page-specific readiness condition, save or return the PNG, and always close the browser.
This guide provides a starting implementation and deployment workflow. Browser packaging depends on the chosen base image, browser build, driver, and architecture, so validate the complete image in your target Lambda environment before relying on it in production.
What you need to package for Selenium screenshots
Selenium is the Python interface that controls a browser through WebDriver; it does not include the browser itself. Your Lambda image therefore needs all of the following:
- The Python Selenium package and your handler code.
- A Linux-compatible Chrome or Chromium binary.
- A WebDriver compatible with that browser build.
- The browser’s required shared libraries and fonts.
- A writable location for browser profile and temporary files, commonly under
/tmp.
Pin and test a compatible browser/driver pair rather than assuming that a package or third-party bundle will remain current. Browser releases and base-image updates can change compatibility.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
Choose a Lambda packaging approach
Container image
A container image is a practical option when the browser binary and native libraries make the complete runtime difficult to package otherwise. AWS supports Python Lambda container images based on an AWS Python image, an AWS OS-only image, or a non-AWS base image. An AWS Python base image includes the runtime and Lambda-related components; if you use an OS-only or other base image, include a compatible Python runtime interface client.
Lambda container images must be Linux-based and target one architecture per function image. AWS sets the maximum uncompressed image size, including layers, at 10 GB. Python 3.12 and later AWS base images use Amazon Linux 2023 and microdnf (also available as dnf); some earlier runtimes use Amazon Linux 2 and yum. Check AWS’s current runtime tags and lifecycle dates before selecting a base image: Deploy Python Lambda functions with container images and Create a Lambda function using a container image.
Layer or other package
A layer or another packaging method may also be workable, but browser dependencies, image size, and native-library compatibility still need validation. The cited AWS container-image guidance does not establish that one approach is universally better for Selenium screenshots; choose based on the size and reproducibility of your browser stack and test the deployed artifact.
Rank #2
- 1.1 GHz (boost up to 2.4GHz) Intel Celeron N5030 Quad-Core
- 4GB DDR4 System Memory; 128GB Solid State Drive
- 11.6" HD (1366 x 768) Multi-Touch Display
- Combo headphone/microphone jack - Noble Wedge Lock slot - HDMI; 2 USB 3.1 Gen 1
- Windows 11 Pro
Write a handler that waits, captures, and cleans up
The example below assumes your image already contains a browser and matching driver accessible to Selenium. It accepts a URL and optional viewport dimensions, writes a PNG to /tmp, and returns it as Base64 in a JSON response. That response method is suitable only when the screenshot fits your invocation’s response path and limits; for durable or larger outputs, upload the file to a storage destination you configure and return a reference instead.
The readiness check looks for a configurable CSS selector. Replace the default with an element that means the page is useful for your specific site. A successful navigation call alone does not prove that client-side rendering, images, or other content is visually complete.
import base64
import json
import os
import tempfile
from urllib.parse import urlparse
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
def lambda_handler(event, context):
url = event.get("url")
if not isinstance(url, str):
return {"statusCode": 400, "body": "Provide a URL string."}
parsed = urlparse(url)
if parsed.scheme not in ("http", "https") or not parsed.netloc:
return {"statusCode": 400, "body": "URL must be an absolute http or https URL."}
width = int(event.get("width", 1280))
height = int(event.get("height", 800))
if not (1 <= width <= 4096 and 1 <= height <= 4096):
return {"statusCode": 400, "body": "Viewport dimensions are out of range."}
selector = event.get("ready_selector", "body")
wait_seconds = float(event.get("wait_seconds", 15))
if wait_seconds <= 0:
return {"statusCode": 400, "body": "wait_seconds must be positive."}
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--window-size={},{}".format(width, height))
options.add_argument("--user-data-dir=" + tempfile.mkdtemp(prefix="chrome-", dir="/tmp"))
driver = None
try:
driver = webdriver.Chrome(options=options)
driver.set_page_load_timeout(min(wait_seconds + 10, 60))
driver.set_window_size(width, height)
driver.get(url)
WebDriverWait(driver, wait_seconds).until(
EC.presence_of_element_located(("css selector", selector))
)
filename = "/tmp/capture.png"
if not driver.save_screenshot(filename):
raise OSError("WebDriver could not save the screenshot")
with open(filename, "rb") as image_file:
encoded = base64.b64encode(image_file.read()).decode("ascii")
return {
"statusCode": 200,
"headers": {"content-type": "application/json"},
"body": json.dumps({"image_base64": encoded, "format": "png"}),
}
except Exception as exc:
print("Screenshot capture failed:", repr(exc))
return {"statusCode": 502, "body": "Screenshot capture failed."}
finally:
if driver is not None:
driver.quit()
Selenium’s save_screenshot(filename) saves the current browser window as a PNG and returns false if it cannot write the file. It also offers get_screenshot_as_png() for PNG bytes and a Base64 screenshot method. See the Python WebDriver API and Selenium getting started guide.
Rank #3
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
The sample’s checks are intentionally basic. For a public endpoint, avoid allowing arbitrary destinations without considering access to internal services, and bound navigation, wait, and output resources. Add authentication, destination controls, logging, and a storage integration appropriate to your application.
Build and deploy the Lambda image
- Create the image. Start from an AWS Python base image for the runtime you selected. Install Selenium and the Linux libraries your chosen browser needs, and copy in a browser and compatible driver. Put your function code under the Lambda task root and configure the image command to your handler.
- Match the architecture. Build for the architecture configured for the function. AWS’s example uses
docker buildx build --platform linux/amd64 --provenance=false; uselinux/arm64when targeting arm64 and ensure the browser and driver support it. - Test the built artifact. Invoke it locally using AWS’s runtime interface emulator, then test in Lambda-like conditions. Confirm browser startup, writable paths, fonts and libraries, screenshot dimensions, wait behavior, and execution timeout.
- Push and deploy. Push the image to Amazon ECR and configure the Lambda function to use it. Publishing a new image to ECR does not, by itself, update the function code: rebuild and update the function when browser, driver, dependencies, or handler code changes. Follow AWS’s container image deployment workflow.
Choose capture readiness and output deliberately
Readiness
Use a selector or condition that reflects the content you need, such as a report heading or product card. A generic body check only confirms that the document body exists. If content renders asynchronously, wait for the relevant element or another explicit condition and keep that wait bounded. Selenium also exposes page-load and script timeout controls; set them to fit within the Lambda execution timeout rather than letting browser work consume the entire invocation.
Viewport and full-page behavior
save_screenshot captures the current browser window. Setting width and height controls the viewport, but does not turn the capture into a full-page screenshot. If you require an entire long page, implement and verify a separate full-page strategy for the browser build you package instead of promising that a normal window capture includes content below the viewport.
Rank #4
- EFFORTLESS EVERYDAY PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 Home system, delivering reliable, low-power efficiency for daily tasks like document editing, email, online classes, and web browsing
- 15.6-INCH FULL HD DISPLAY: Enjoy immersive visuals on the 15.6" FHD (1920x1080) anti-glare screen with micro-edge bezels. Delivers clear details and comfortable viewing for long study sessions, working on spreadsheets, and video playback
- RESPONSIVE MULTITASKING & STORAGE: Built with 4GB LPDDR4 RAM and 128GB eMMC storage for smooth daily essential use. Expand your storage by up to 1TB via the integrated TF card slot to easily store movies, photos, and working files
- ADVANCED CONNECTIVITY: Outfitted with 2x Full-Featured Type-C ports for data transfer, fast charging, and dual-monitor output, alongside 2x USB 3.2 Gen1 ports and a 3.5mm audio jack for complete peripheral compatibility
- LIGHTWEIGHT & SILENT OPERATION: Slim and portable for effortless travel or commuting. Features a 1MP HD webcam for remote meetings, 38Wh battery with 45W Type-C fast charging, and a fanless silent design for peaceful work environments.
Output destination
- Return bytes: capture with
get_screenshot_as_png()or read a temporary PNG and encode it for a response when the output is suitably small. - Persist a file: write to a configured storage service and return a key or URL when the image must outlive the invocation or the response path is unsuitable.
- Temporary files: use writable temporary storage for the browser profile and intermediate image, and do not assume temporary files are a durable destination.
Performance, reliability, and cost considerations
Browser startup, page behavior, image size, and dependency loading determine how an invocation performs. No fixed latency or cold-start figure applies across browser builds and target sites. Keep the browser and driver versions pinned, use bounded timeouts, and test the exact image after updates. A browser failure, slow navigation, or a page that never meets its readiness condition should produce a controlled error rather than leave the invocation waiting indefinitely.
Set the Lambda memory and execution timeout to values validated under your workload; this guide does not provide benchmark-derived settings. Include the time for browser startup, page navigation, readiness, and output handling in your timeout budget. For recurring browser-based synthetic monitoring rather than a custom screenshot handler, AWS CloudWatch Synthetics canaries provide programmatic browser access through Playwright, Puppeteer, or Selenium WebDriver: Synthetic monitoring (canaries).
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting common failures
- Chrome or driver cannot start: confirm both binaries are present, executable, compatible with one another, and built for the function’s Linux architecture. Check missing shared libraries and the browser’s startup logs.
- Browser exits or cannot create a profile: direct profile and temporary files to writable storage such as
/tmp; verify that the configured path exists and is writable. - Navigation times out: check the target’s response and redirects, lower the navigation timeout to fit the Lambda budget, and wait separately for a meaningful page condition. Avoid treating navigation completion as proof that all visual content is ready.
- Screenshot is blank or incomplete: choose a stronger readiness condition, check whether the site requires authentication or client-side rendering, and verify viewport and page state before capture.
- Screenshot file is missing: check the boolean result from
save_screenshot, catch file I/O errors, and read or upload the file before the handler returns. - Deployment still runs old code: updating ECR alone does not update the Lambda function’s deployed image reference. Update the function after publishing the new image.
- Image build or deployment rejects the artifact: confirm it is Linux-based, built for one architecture matching the function, and within the 10 GB uncompressed image limit.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF; cookie banners, newsletter popups, and chat widgets are removed before capture. Bot checks, blank pages, and failed loads are never billed, and responses identify the page verdict and billing status. Its MCP server lets AI agents use screenshot tools, and it supports 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11For API details and parameters, see the ScreenshotNeo documentation.
Best Value
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Sign up for ScreenshotNeo free to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Does Selenium’s regular screenshot method capture the whole webpage?
No. It captures the current browser window; a full-page result requires a separate implementation that you validate with your packaged browser.
Can AWS CloudWatch Synthetics run Selenium?
AWS documents canary runtimes with browser automation through Selenium WebDriver as well as Playwright and Puppeteer.
Recommended Free Tools
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.




