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

Use Selenium to run current unified Headless Chrome, make the page background transparent, set Chrome DevTools Protocol’s default frame color to RGBA alpha 0, and capture PNG data with Page.captureScreenshot. PNG preserves the alpha channel; Selenium’s ordinary save_screenshot() call does not configure transparency by itself.

What you need

  • Python 3 and a current Selenium package (pip install selenium).
  • Chrome and a ChromeDriver version compatible with that Chrome installation. Selenium Manager can usually locate the driver automatically.
  • A page whose CSS does not paint an opaque background on html, body, a root application element, canvas, or the component being captured.
  • A PNG output file. JPEG cannot store an alpha channel.

Google’s current architecture uses unified Headless Chrome, which shares code with headful Chrome. Since Chrome 132, the older implementation is distributed separately as chrome-headless-shell; use unified Headless unless a specific compatibility requirement says otherwise.

Capture a transparent viewport screenshot in Python

This complete example navigates, sets a deterministic viewport, applies the alpha-zero background override, calls the DevTools Protocol capture method, and decodes its base64 result.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import base64

options = Options()
options.add_argument("--headless=new")
options.add_argument("--window-size=1280,900")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com/transparent-page")

    # The override is used only where page content has not specified a color.
    driver.execute_cdp_cmd(
        "Emulation.setDefaultBackgroundColorOverride",
        {"color": {"r": 0, "g": 0, "b": 0, "a": 0}},
    )

    result = driver.execute_cdp_cmd(
        "Page.captureScreenshot",
        {"format": "png", "fromSurface": True},
    )
    with open("transparent.png", "wb") as output:
        output.write(base64.b64decode(result["data"]))
finally:
    driver.quit()

The exact CDP helper name can vary between Selenium bindings and versions. In Python, execute_cdp_cmd is the usual interface; if your installed binding exposes a differently cased helper, consult that binding’s API and keep the protocol method names and parameter structure unchanged.

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.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Make the page itself transparent

setDefaultBackgroundColorOverride changes the frame’s default only when content does not specify a background. A stylesheet such as body { background: white; }, an opaque root container, or a canvas still paints pixels. For a page you control, use transparent backgrounds:

html, body, #app {
  background: transparent !important;
}

For a page you do not control, inject a narrowly scoped rule before capture when that is acceptable:

driver.execute_script("""
  document.documentElement.style.background = 'transparent';
  document.body.style.background = 'transparent';
""")

This does not make every descendant transparent. Inspect the computed styles of the root, body, canvas, and the element you intend to capture, and remove or override only the opaque layers that should not appear.

Why Headless Chrome returns a white background

  • The page specified white. The protocol override is not a force-clear operation; author CSS wins.
  • A framework root or canvas is opaque. React, Vue, game canvases, and design-system shells commonly set a background below body.
  • You are viewing a composited preview. Some image viewers display transparency as white. Inspect the PNG’s alpha channel over a checkerboard or contrasting background.
  • You saved a different format. JPEG has no alpha channel. Request PNG and write the decoded PNG bytes unchanged.
  • The capture happened before the page was ready. Wait for a selector, fonts, images, or application rendering before invoking CDP.

Control viewport size and capture scope

Repeatable viewport captures

--window-size=1280,900 makes layout and output dimensions predictable. Set it before navigation so responsive breakpoints are selected consistently. You can also use Selenium window or DevTools metrics APIs when your binding requires more precise device scale, but keep width, height, and scale fixed in automated jobs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Page.captureScreenshot supports a clip for a particular viewport region. A CDP clip uses CSS-pixel coordinates and can include x, y, width, height, and scale. Verify the parameter spelling accepted by your Selenium version.

Full-page and beyond-viewport output

A normal viewport capture does not automatically include content below the fold. First obtain document dimensions, then use your binding’s current full-page or beyond-viewport support. Selenium method names differ across language bindings and releases, so inspect the installed API rather than copying a method name blindly. Chromium’s protocol tests cover transparent captures beyond the viewport, but the capability still depends on using the correct current binding and capture parameters.

dimensions = driver.execute_script("""
  const e = document.documentElement;
  const b = document.body;
  return {
    width: Math.max(e.scrollWidth, b ? b.scrollWidth : 0),
    height: Math.max(e.scrollHeight, b ? b.scrollHeight : 0)
  };
""")
print(dimensions)

For a long page, lazy-loaded images may not exist until their sections are scrolled into view. Scroll through the document (or use an application-specific loading strategy), wait for images to finish, then perform the beyond-viewport capture. Check the resulting pixel dimensions and alpha channel; a screenshot that is merely tall is not proof that every section rendered transparently.

Waiting, dynamic content, and page preparation

  1. Navigate to the final URL.
  2. Wait for a stable application marker with WebDriverWait, or wait for network/application idle using a strategy appropriate to the site.
  3. Trigger required interactions, such as opening a menu or dismissing a dialog, before capture.
  4. Apply transparency CSS and the CDP override after the page is attached and before the screenshot.
  5. Capture PNG and close the driver in a finally block.

Animations, blinking cursors, time-dependent content, and late web fonts can make otherwise identical runs differ. Disable animations with an injected stylesheet when visual determinism matters, and use explicit waits instead of arbitrary short sleeps. A transparent background does not alter cookies, authentication, permissions, or cross-origin security rules; those still need to be configured normally in Selenium.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Checking that the PNG really has transparency

  • Open the file over both a dark and a light background in an image editor.
  • Use an image-inspection tool to confirm the PNG has an alpha channel and that background pixels have alpha 0 where expected.
  • Check a pixel inside visible content as well as an empty corner; a file can contain an alpha channel while still painting an opaque rectangle.
  • Compare output dimensions with the requested viewport or full-page dimensions.

A checkerboard shown by a viewer is only a presentation convention. It does not prove that the stored pixels are transparent.

Selenium’s built-in screenshot methods versus CDP

Method Best use Transparency behavior
driver.save_screenshot("page.png") Ordinary current-window PNG Does not by itself set an alpha-zero frame background.
Element screenshot methods One selected element Useful for ordinary element images; transparent output still requires transparent page styling and the CDP override/capture path.
Page.captureScreenshot Protocol-level viewport, clip, and beyond-viewport capture Use format: "png", fromSurface: true, and the Emulation background override.

Troubleshooting transparent captures

Everything is opaque

Inspect computed backgrounds on html, body, the framework root, canvases, and pseudo-elements. Remove the rule that paints the unwanted layer, then reapply the alpha-zero override.

unknown command or CDP failure

Confirm that the browser is Chrome/Chromium, not an incompatible browser, and that ChromeDriver matches the installed Chrome version. Update Selenium and use the CDP command interface shipped by that version. Unified Headless is the preferred current mode.

The helper method is missing

CDP convenience methods are binding-version details. Check your Selenium language binding’s documentation or use its current DevTools interface; do not assume Python naming is identical in Java, JavaScript, or another language.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

The screenshot is cropped

You captured the viewport, not the document. Measure scroll dimensions and use the binding’s full-page/beyond-viewport option. Ensure lazy content was loaded before measuring.

The file opens but has no alpha

Verify format is png, decode the returned base64 string, and write binary bytes. Do not convert to JPEG after capture.

Output changes between runs

Fix window metrics, wait for a stable selector, freeze or disable animations, allow fonts and images to finish, and control timezone or locale when page content depends on them.

Only a white rectangle around one widget remains

The widget itself owns an opaque background. Target that component’s CSS or capture a transparent wrapper only after the component has been rendered without its background. The frame override cannot remove pixels intentionally painted by the component.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
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 provides a website screenshot API and MCP server. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, with the result identified by response headers. It supports transparent backgrounds, full-page captures, CSS selectors, custom JavaScript and CSS, waits, device and viewport settings, and PNG, JPEG, WebP, or PDF output. Its MCP tools let Claude, Cursor, or another MCP client call take_screenshot, get_page_info, and capture_pdf.

Use the API call shown in the ScreenshotNeo documentation:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Sign up free for ScreenshotNeo.

Operational and cost considerations

  • Keep Chrome and ChromeDriver compatible and pin versions in CI when reproducibility matters.
  • Reuse a driver for a controlled batch, but isolate jobs that require different cookies, profiles, or browser flags.
  • Set explicit page-load and script timeouts, and always quit the driver after failures.
  • Record URL, viewport, Chrome version, Selenium version, and capture parameters beside generated artifacts.
  • For high-volume work, account for browser startup time, memory used by full-page pages, retries, and the cost of loading third-party resources.
  • With an API service, check the response’s page verdict and billing headers so failed loads and cache behavior are visible rather than inferred from the image alone.

Final verification checklist

  • Chrome runs in current unified Headless mode.
  • ChromeDriver matches Chrome.
  • Viewport dimensions are fixed.
  • Root and target backgrounds are intentionally transparent.
  • Emulation.setDefaultBackgroundColorOverride uses r: 0, g: 0, b: 0, a: 0.
  • Page.captureScreenshot requests PNG.
  • Full-page output uses verified beyond-viewport support.
  • The saved PNG’s alpha channel has been inspected.

Frequently Asked Questions

Can a transparent screenshot be saved as JPEG?

No. JPEG has no alpha channel; use PNG for transparent pixels.

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.

Does the alpha-zero override remove a page’s white CSS background?

No. It supplies the frame default only when content does not specify a background. Author CSS, canvases, and opaque components must be changed separately.

Is a tall screenshot automatically a full-page screenshot?

No. Confirm that your Selenium binding used a full-page or beyond-viewport capture and that lazy content was loaded.

Which Chrome headless implementation should new projects use?

Use unified Headless Chrome. The older implementation is a separate chrome-headless-shell binary from Chrome 132 onward.

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.

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