Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober 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 Scan×
Skip to content
browser automation

How to Capture Website Screenshots with MDN’s WebDriver BiDi Screenshot API

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

For an automated website screenshot, use the WebDriver BiDi command browsingContext.captureScreenshot. It requires an established BiDi connection, an active browser session, and the ID of the browsing context you want to capture. With no origin, the command captures the visible viewport; set origin to document for the full scrollable page. The result is Base64-encoded image data that your program must decode and save.

MDN does not define a standalone product called the “MDN Screenshot API.” The phrase usually refers to this WebDriver BiDi command. It is different from the Screen Capture API’s getDisplayMedia(), which asks a person to choose a tab, window, or monitor for sharing.

What the MDN screenshot command captures

browsingContext.captureScreenshot operates inside a WebDriver BiDi session. The request identifies a browsing context and can optionally specify the capture origin, output format, quality, and clipping region. MDN’s command reference is the authoritative description: browsingContext.captureScreenshot.

Goal Request setting Result
Current viewport Omit origin Only the currently visible browser viewport
Full page origin: "document" The scrollable document, including content below the viewport
One element clip: {type: "element", element: ...} The element identified by a WebDriver shared ID
Rectangle clip: {type: "box", x, y, width, height} A custom rectangular crop

PNG is the default. You can request an image MIME type such as image/png or image/jpeg. For lossy formats such as JPEG, quality ranges from 0.0 to 1.0. If quality is omitted, the browser chooses its compression behavior.

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

Prerequisites and session flow

  • A browser or automation driver that exposes a WebDriver BiDi connection.
  • An active WebDriver session and its browsing-context ID.
  • Code that can send BiDi commands and decode Base64 responses.

The command is a protocol message, not something you paste into a normal browser console. Your automation code must first create a session, navigate to the target URL, and retain the context ID. The exact session-start and connection details depend on your WebDriver BiDi client and browser; use that client’s current documentation for those steps.

The essential message

{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID"
  }
}

The response contains an object with Base64 image data. Decode that value as bytes and write it with a .png extension unless you requested another format.

Viewport, full-page, and JPEG examples

Capture the visible viewport

{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID"
  }
}

Because origin is omitted, this captures what is visible in the context at that moment. Wait for navigation and any application-specific rendering before sending the command.

Capture the complete scrollable document

{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID",
    "origin": "document"
  }
}

This is the WebDriver BiDi equivalent of a full-page screenshot. Very tall pages can create large image files and consume more memory than a viewport capture, so use it selectively for long documents.

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.
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

Request a compressed JPEG

{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID",
    "origin": "document",
    "format": {
      "type": "image/jpeg",
      "quality": 0.8
    }
  }
}

JPEG is useful when file size matters and minor lossy compression is acceptable. Choose PNG for sharp text, transparency, or pixel-level comparisons.

Capture an element or a custom rectangle

Element clipping

Element clipping requires a WebDriver shared element ID. Obtain that ID with browsingContext.locateNodes, or by evaluating or calling a script that returns the element. Then include it in the clip:

{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID",
    "clip": {
      "type": "element",
      "element": {
        "sharedId": "YOUR_ELEMENT_SHARED_ID"
      }
    }
  }
}

The element can be outside the currently visible area; the browser uses its rendered bounds. The element must belong to the document in the context being captured.

Rectangular clipping

For a fixed crop, provide a box with offsets and dimensions. Coordinates and dimensions must describe a non-empty region that intersects the capture origin:

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.
{
  "method": "browsingContext.captureScreenshot",
  "params": {
    "context": "YOUR_BROWSING_CONTEXT_ID",
    "clip": {
      "type": "box",
      "x": 0,
      "y": 120,
      "width": 960,
      "height": 540
    }
  }
}

Use element clipping when the target is a semantic page component; use a box when the crop is defined by exact coordinates.

Do not confuse screenshots with screen sharing

getDisplayMedia(), documented in MDN’s Screen Capture API reference, starts a display-media stream after the user chooses a surface. A browser can offer a tab, complete window, or monitor. It is intended for sharing or recording, not silent server-side page capture.

Screen capture has a user-permission model: a recent user interaction (transient activation) is required, and the browser still presents a selection prompt. A site’s Permissions-Policy header or an iframe’s allow attribute can control whether display capture is permitted, but policy does not remove the prompt. MDN marks this API as limited availability and not Baseline, so check the current compatibility table before targeting a particular browser.

Turning a display stream into a still image

If a human-selected display stream is genuinely what you need, MDN’s Element and Region Capture guide describes obtaining a frame with ImageCapture.grabFrame(), drawing the resulting ImageBitmap to a canvas, and exporting it with HTMLCanvasElement.toBlob(). This still requires display selection and permission; it is not equivalent to browsingContext.captureScreenshot.

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.
Rank #4
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

Element Capture limits a stream to a selected DOM tree and descendants. Region Capture uses a tab region’s bounding box and may include content that overlaps that region. Choose Element Capture when excluding material outside a DOM tree (for example, private notifications or speaker notes) is important; choose Region Capture when the physical tab region is the desired output.

Troubleshoot protocol errors

Error Likely cause Fix
invalid argument A required parameter is missing or has the wrong type. Verify the context string, clip object, format MIME type, and numeric quality value.
no such element The shared element ID cannot be resolved or belongs to another context’s document. Locate the element again in the target context immediately before capture.
no such frame The context ID is unknown or the session no longer owns it. Use the context ID returned by the current session and recreate the session if it was closed.
unable to capture screen The requested clip has zero width or height, or does not intersect the capture origin. Inspect the element’s rendered bounds or adjust the rectangle to a non-empty area.
unsupported operation The browser cannot capture that context. Check the browser/driver’s current BiDi support and try a supported context.

Blank or incomplete images

  • Wait for navigation and application rendering before capture; a command sent too early can record an intermediate state.
  • For lazy-loaded pages, ensure the page has actually rendered the content you expect before requesting origin: "document".
  • Confirm that you decoded the response’s Base64 data rather than writing the Base64 text itself.
  • Check that your output extension matches the requested format.

Performance, reliability, and format choices

Viewport captures are generally smaller and faster to transfer than full-document captures. Full-page images grow with document height, while element and rectangle clips reduce both image dimensions and memory use. JPEG can reduce storage for photographic pages; PNG preserves text and sharp edges.

For repeatable automation, wait on a page-specific readiness condition rather than an arbitrary short delay, keep the context ID associated with the same session, and treat each capture as binary data. If a page can change during rendering, capture only after its main content and fonts have loaded. A failed command should be retried only after checking whether the context, element, or clip is still valid; blindly repeating an invalid request will not fix it.

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

ScreenshotNeo provides a hosted screenshot API and MCP server, so you can request an image without managing a WebDriver BiDi session. It accepts a URL and returns PNG, JPEG, WebP, or PDF. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. 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.

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

One call is enough:

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

See the ScreenshotNeo documentation for all parameters, including full-page capture, CSS-selector elements, device presets, retina scale, PDF settings, custom CSS and JavaScript, clicks, waits, blocking rules, headers, cookies, user agents, timezone, geolocation, transparent backgrounds, resizing, caching, signed links, asynchronous webhooks, bulk capture, usage, and the OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

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.

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently asked questions

Does the command require a visible browser window?

The documented workflow requires a WebDriver BiDi connection and active session; whether the browser is headed or headless depends on the browser and driver configuration you choose.

Can I select a screenshot format other than PNG?

Yes. Supply a supported image MIME type in format.type; JPEG quality is controlled with a value from 0.0 to 1.0.

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

Is a full-page capture the same as scrolling and stitching screenshots?

No. The BiDi command requests the document origin directly with origin: "document"; it does not require your code to stitch viewport images.

Frequently Asked Questions

What is the MDN Screenshot API called?

The browser-automation command documented by MDN is WebDriver BiDi’s browsingContext.captureScreenshot; “MDN Screenshot API” is informal wording, not a separate API product.

What does a WebDriver shared element ID mean?

It is the protocol identifier returned when WebDriver locates or evaluates a DOM element. Use that identifier in an element clip, and obtain it in the same browsing context you capture.

When should I use Screen Capture API instead?

Use getDisplayMedia() when a person must choose a tab, window, or monitor to share or record. Use WebDriver BiDi for automated page, document, element, or rectangle screenshots.

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 *

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

Read next

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.