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

For a saved image of one HTML element, use browser automation and target that element directly. With Playwright, call locator.screenshot() to save the element as an image. Chrome’s similarly named Element Capture API serves a different purpose: it restricts a live tab-capture video stream rather than saving a conventional still image.

Capture one element as a still image with Playwright

Playwright’s element screenshot method targets a locator and saves the image to a file. The locator can identify an element with a CSS selector, such as #chart or .product-card. Install Playwright and its Chromium browser, then run this example:

  1. npm init -y
  2. npm install playwright
  3. npx playwright install chromium
  4. Save the following as element-shot.js and run it with node element-shot.js.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage({ viewport: { width: 1280, height: 900 } });

  try {
    await page.goto('https://example.com', { waitUntil: 'networkidle' });
    const target = page.locator('#chart');
    await target.waitFor({ state: 'visible' });
    await target.screenshot({ path: 'element.png' });
  } finally {
    await browser.close();
  }
})();

Replace https://example.com with the page to capture and #chart with a selector for the desired element. The script waits for the target to become visible, then writes element.png in the current directory. Playwright’s screenshot documentation describes targeting an element or selector, choosing an output format and scale, and notes that full-page capture cannot be combined with an element target: Playwright screenshots.

Wait for the content you actually need

Visibility alone does not guarantee that a chart, image, or asynchronously rendered widget is finished. If the page exposes a reliable ready state, wait for it before taking the screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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
await page.locator('#chart-ready').waitFor({ state: 'visible' });
await page.locator('#chart').screenshot({ path: 'chart.png' });

For a selector that appears after a known delay, use a locator wait rather than an arbitrary pause wherever possible. If the page keeps network connections open, waitUntil: 'networkidle' can be unsuitable; navigate with a less restrictive load state and wait for the element or application-specific ready signal instead.

Format, scale, and full-page limits

Playwright documents PNG, JPEG, and WebP output and supports CSS-pixel sizing or device-pixel-ratio scaling. Select a format appropriate to the use: PNG is a lossless general-purpose choice, while JPEG and WebP can produce smaller files depending on image content and settings. Element capture concerns the target itself; the full-scrollable-page option is not compatible with an element target.

When Chrome Element Capture is the right tool

Use Chrome’s Element Capture API when the goal is to restrict a live tab-capture video track to one element and its descendants, such as when capturing or sharing a region during a live session. It is not the ordinary route for saving a single PNG file. Chrome for Developers describes it as a way to capture and record a specific HTML element: Element Capture API.

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

The documented flow obtains the current tab’s display media, creates a restriction target from the element, and applies that target to the video track:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
async function captureElement(captureTarget) {
  if (!('RestrictionTarget' in window) ||
      typeof RestrictionTarget.fromElement !== 'function') {
    throw new Error('Element Capture is not available in this browser.');
  }

  const stream = await navigator.mediaDevices.getDisplayMedia({
    preferCurrentTab: true,
    video: true
  });

  const track = stream.getVideoTracks()[0];
  if (!track) {
    stream.getTracks().forEach((item) => item.stop());
    throw new Error('No video track was returned.');
  }

  try {
    const restrictionTarget = await RestrictionTarget.fromElement(captureTarget);
    await track.restrictTo(restrictionTarget);
    return { stream, track };
  } catch (error) {
    stream.getTracks().forEach((item) => item.stop());
    throw error;
  }
}

// Example: request capture, then restrict it to #shared-region.
const target = document.querySelector('#shared-region');
const { stream, track } = await captureElement(target);

// When finished, stop the capture tracks.
stream.getTracks().forEach((item) => item.stop());

The browser may require the user to choose or authorize a capture surface; this is a live capture flow, not a silent page screenshot. Feature-detect both RestrictionTarget and fromElement before using it. Chrome documents availability from Chrome 132 on desktop and says the feature is currently enabled only for self-capture. Although restrictTo() is exposed on tab-capture video tracks more generally, that does not mean every capture setup is supported.

Make the target eligible

The target must be a suitable, cohesive two-dimensional rectangular region, and its pixels must be separable from its parent and siblings. Chrome recommends that it form its own stacking context; setting isolation: isolate on the target is one way to do that:

Rank #3
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.
#shared-region {
  isolation: isolate;
}

An element with display: none, or one inside a display: none ancestor, does not produce frames. If style or layout changes later make the target ineligible, new frames stop until eligibility returns.

Understand what the stream includes

Restriction applies to the chosen element and its descendants; siblings and content that occludes or is occluded by it are removed from resulting frames. The live video capture does not carry an alpha channel. Removing alpha can alter apparent colors or expose transparent pixels as black, so check the actual stream before using it for overlays or privacy-sensitive sharing.

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

Which Chromium route fits the job?

Need Use Important distinction
Save one DOM element as an image file Playwright element screenshot Targets an element or selector for a still image.
Restrict a live capture or sharing stream to a DOM region Chrome Element Capture API Works on a video track; it is not a saved-image API.
Build a browser extension or low-level Chromium debugger integration Chrome debugger API with additional CDP implementation The debugger reference does not provide a ready-made element-screenshot recipe.

Extension and debugger considerations

Chrome documents chrome.debugger as an alternate transport for the Chrome DevTools Protocol (CDP). An extension using it must declare the debugger permission in its manifest. The API reference also warns that enterprise DisableScreenshots policy or data-loss-prevention restrictions may cause debugger attachment to fail with a screenshot-restriction error: Chrome debugger API. This is a lower-level route; consult the relevant CDP implementation details for the specific capture workflow rather than treating the extension API itself as an element screenshot method.

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

Troubleshooting element capture

Playwright says the locator matched no element or timed out

  • Check that the selector matches the rendered page, including any iframe or shadow-DOM boundary involved.
  • Wait for the application to render the target before capturing it; use a visible-state wait or an application-specific ready signal.
  • If the element is below the fold, Playwright’s locator screenshot can scroll it into view; confirm the page has not hidden or removed it before the capture.

The image is empty, incomplete, or shows the wrong state

  • Wait for images, fonts, charts, or application data that render after navigation.
  • Use a deterministic viewport and page state when comparing screenshots across runs.
  • If using full-page capture, remember it cannot be combined with an element target; capture the element directly instead.

Element Capture produces no frames or fails to restrict the track

  • Verify the browser exposes RestrictionTarget.fromElement, the target still exists in the originating tab, and the track is a supported self-capture video track.
  • Do not use a cloned track; Chrome lists cloned tracks among the failure cases.
  • Check target eligibility: it must be rendered, geometrically suitable, and separable from surrounding content. Try establishing a stacking context with isolation: isolate.
  • Re-create the restriction target if the originating element was removed or the capture is now in a different tab.

Extension debugger attachment is blocked

Confirm the extension declares the debugger permission. On a managed device, ask the administrator whether screenshot policy or DLP restrictions block debugger attachment; page JavaScript cannot override an organization-level policy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot of a URL without maintaining a Chromium automation script, ScreenshotNeo is a website screenshot API and MCP server. It captures pages by URL and can also capture an element with a CSS selector. For example, this cURL request asks for an element screenshot from a page:

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

See the ScreenshotNeo API documentation for authentication and supported parameters. ScreenshotNeo removes known consent banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers indicate the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients.

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

The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

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.

Frequently Asked Questions

Can Chrome Element Capture save a PNG file?

It restricts a live video track rather than providing the usual saved-image operation. Use a browser automation screenshot method for a PNG still.

Does Element Capture work in every Chromium browser?

Chrome documents the feature from Chrome 132 on desktop and says it is currently enabled only for self-capture. Availability in other Chromium-based browsers is not established here.

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.