October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Save Selenium Screenshots Directly to an S3-Compatible Storage Bucket

Use Selenium’s PNG bytes and Boto3’s upload_fileobj to send screenshots straight to an S3-compatible bucket without saving a local image first.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Capture a Selenium screenshot as PNG bytes, wrap those bytes in a binary in-memory stream, and pass the stream to Boto3’s upload_fileobj. This sends the screenshot to an S3-compatible bucket without first creating an image file on disk.

Upload a Selenium screenshot from memory

Selenium’s Python WebDriver method get_screenshot_as_png() returns PNG data as bytes. Boto3’s upload_fileobj accepts a readable binary file-like object, so io.BytesIO can connect the two without an intermediate disk file.

As an Amazon Associate I earn from qualifying purchases.

Install the Python packages in the environment where the script will run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install selenium boto3

The browser driver must also be available to Selenium in your environment. Then configure the endpoint and credentials for your storage provider and run:

#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
from io import BytesIO
import os

import boto3
from selenium import webdriver

# Set these values for your provider and environment.
endpoint_url = os.environ["S3_ENDPOINT_URL"]
bucket_name = os.environ["S3_BUCKET"]
access_key = os.environ["S3_ACCESS_KEY"]
secret_key = os.environ["S3_SECRET_KEY"]
region_name = os.getenv("S3_REGION", "us-east-1")

s3 = boto3.client(
    "s3",
    endpoint_url=endpoint_url,
    region_name=region_name,
    aws_access_key_id=access_key,
    aws_secret_access_key=secret_key,
)

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")

    screenshot = BytesIO(driver.get_screenshot_as_png())
    screenshot.seek(0)

    s3.upload_fileobj(
        screenshot,
        bucket_name,
        "selenium/example.png",
        ExtraArgs={"ContentType": "image/png"},
    )
finally:
    driver.quit()

After a successful upload, the object key is selenium/example.png in the configured bucket. Change the URL and key to suit your job. The ContentType extra argument marks the object as a PNG for clients that use its object metadata.

Configure the S3-compatible endpoint safely

This example assumes the bucket already exists, the process can read its configured credentials, and the identity has permission to write the requested key. The environment-variable names and the default region shown are example configuration choices, not universal settings for S3-compatible services. Keep access keys out of source control and avoid logging them.

Rank #2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Boto3’s session reference describes endpoint_url as a complete custom endpoint URL. Consult your provider’s current instructions for the endpoint scheme and host, region and signing expectations, authentication, TLS certificate requirements, addressing style, and supported operations. Boto3’s S3 examples caution that endpoint overrides can produce unintended behavior, including redirects; test the exact endpoint and bucket configuration you plan to use.

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

Choose between memory and a local file

Approach What the code passes to Boto3 When it fits
In memory A binary stream created from Selenium’s PNG bytes, passed to upload_fileobj. When the workflow only needs the bucket object and does not need a local image artifact.
Local file A filename passed to upload_file after Selenium saves the screenshot. When another step needs the image on disk or you want to retain a local copy.

Boto3 documents upload_fileobj as a managed transfer that can use multipart upload in multiple threads when necessary. The in-memory route avoids a separate screenshot file, but the screenshot bytes still occupy process memory while being captured and uploaded.

Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Keep a local PNG as well

Selenium’s save_screenshot saves the current window to a PNG file and returns False on an I/O error. Boto3’s upload_file takes a filename, bucket name, and object key:

from selenium import webdriver
import boto3
import os

bucket_name = os.environ["S3_BUCKET"]
s3 = boto3.client(
    "s3",
    endpoint_url=os.environ["S3_ENDPOINT_URL"],
    region_name=os.getenv("S3_REGION", "us-east-1"),
    aws_access_key_id=os.environ["S3_ACCESS_KEY"],
    aws_secret_access_key=os.environ["S3_SECRET_KEY"],
)

driver = webdriver.Chrome()
try:
    driver.get("https://example.com")
    if not driver.save_screenshot("screenshot.png"):
        raise OSError("Selenium could not save screenshot.png")
    s3.upload_file("screenshot.png", bucket_name, "selenium/example.png")
finally:
    driver.quit()

Troubleshoot failed captures and uploads

  • Endpoint or redirect errors: Check that S3_ENDPOINT_URL is the complete URL your provider specifies, including the scheme. Verify region/signing expectations and addressing style, and check whether the provider redirects requests to another endpoint.
  • Access denied: Confirm that the bucket exists, the credentials belong to the intended identity, and that identity is allowed to write the precise object key.
  • Connection or TLS errors: Check network access, the endpoint hostname, and whether your environment trusts the certificate chain required by the provider.
  • Invalid stream or empty upload: Pass a binary file-like object. If you read from the stream before upload, reset it with seek(0); the example does this before calling upload_fileobj.
  • Browser startup or navigation failure: Verify that Chrome and its driver are available in the runtime and that the target page can load from it. The finally block closes the browser even when capture or upload raises an exception.
  • Unexpected object metadata: For the in-memory example, retain ContentType: image/png if consumers rely on the object being identified as a PNG. The file-based example omits that extra argument.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo can return a screenshot or PDF with one GET request; its API documentation is at screenshotneo.com/docs. For example, save a PNG response with cURL:

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$129.99
Bestseller No. 2
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80
Bestseller No. 4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$208.99
Rank #4
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. See ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.