The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →To screenshot one element selected by CSS, wait for the page and the element, create a locator or element handle, then call the framework’s element screenshot method. In Playwright, the core operation is await page.locator('.target').screenshot({ path: 'element.png' }); in Puppeteer, wait for the selector and call element.screenshot({ path: 'element.png' }). Both methods scroll the element into view and save only its rendered bounds.
The CSS-selector screenshot algorithm
A CSS selector does not create an image by itself. It identifies a DOM node; the browser automation library resolves that node, determines its rendered rectangle, scrolls it into view if necessary, and captures the pixels inside that rectangle.
- Open the page in a real browser context.
- Wait until the target selector exists and the page state is suitable for capture.
- Resolve the selector to a locator or element handle.
- Scroll the target into view and let the framework perform its readiness checks.
- Capture the target’s rendered region, optionally applying masks, animation settings, or a stylesheet.
- Write the PNG, JPEG, or other supported output to disk or a buffer.
This is an element screenshot, not a full-page screenshot. A fixed header, consent dialog, or overlay can cover pixels in the target area, and a scrollable target captures only the portion currently visible inside its box.
Choose a selector that expresses intent
Playwright accepts CSS selectors through page.locator(), but its locator guidance cautions against long selectors coupled to incidental DOM structure. A class name or deep descendant chain can change during a redesign even when the user-facing feature is unchanged. Prefer a stable class, an explicit test ID, or a locator based on role, label, or text when those describe the element’s contract. CSS remains useful when the page exposes a reliable hook or when you are automating a site you do not control.
PC 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 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- 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
| Selector | Typical use | Stability consideration |
|---|---|---|
.product-card |
Capture every card or a known card class | Good only if the class is an intentional styling or automation hook |
[data-testid='invoice-total'] |
Capture a test-contract element | Usually stable when the team treats the test ID as an API |
main article h1 |
Quickly target a structural region | Can break when layout or nesting changes |
#receipt |
Capture a unique element by ID | Stable if the ID is guaranteed unique and permanent |
Playwright: capture an element by CSS
Minimal Node.js example
Install Playwright, then launch a browser, navigate, and capture the locator. The locator is resolved when the screenshot is taken, so it can cope better with a page that renders the element after navigation.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
const card = page.locator('.product-card');
await card.screenshot({ path: 'product-card.png' });
await browser.close();
})();
The documented locator screenshot API clips the output to the matched element. Playwright performs locator actionability checks and scrolls the target into view before capture. See the Playwright element and screenshot API documentation and Playwright locator guidance.
Wait for dynamic content explicitly
Navigation completion does not guarantee that an image, chart, or client-rendered component is ready. Wait for the selector that proves the component exists, and add a state-specific wait when the page has a known loading transition.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com/dashboard', { waitUntil: 'networkidle' });
const chart = page.locator('[data-testid="revenue-chart"]');
await chart.waitFor({ state: 'visible' });
await chart.screenshot({ path: 'revenue-chart.png' });
await browser.close();
})();
Use a meaningful readiness condition rather than an arbitrary long delay. If the selector appears before its data is painted, wait for a child label, a loaded-state attribute, or another observable condition your application provides.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 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
Python Playwright variant
The same algorithm is available in Python. This synchronous example is complete and writes a PNG.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(viewport={"width": 1440, "height": 900})
page.goto("https://example.com", wait_until="domcontentloaded")
page.locator(".product-card").screenshot(path="product-card.png")
browser.close()
Make Playwright captures repeatable
Animated components and changing data can produce different pixels on every run. Playwright documents screenshot controls for this situation:
- Disable animations: use the screenshot option that disables CSS transitions and animations while the capture is made.
- Mask dynamic or sensitive regions: provide locators for timestamps, avatars, rotating ads, or personal data so those areas are covered consistently.
- Apply a temporary stylesheet: use a capture-time style to hide cursors, caret blinking, or other visual noise without modifying production code.
Keep the mask and stylesheet close to the screenshot code so a future maintainer can see why a region is intentionally altered. The relevant option behavior is described in Playwright’s locator screenshot details.
Puppeteer: capture an element by CSS
Minimal Node.js example
Puppeteer’s element workflow is explicit: wait for the CSS selector, receive an element handle, and call its screenshot method.
Rank #3
- 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.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 900 });
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
const element = await page.waitForSelector('.product-card');
await element.screenshot({ path: 'product-card.png' });
await browser.close();
})();
This follows the pattern in Puppeteer’s screenshots guide (the guide identifies version 25.12.0). Puppeteer scrolls an element into view when needed. If the node is detached from the DOM before the screenshot runs, ElementHandle.screenshot() throws; reacquire the selector after the page finishes replacing the component. See the ElementHandle screenshot reference.
Use Puppeteer locators when automatic waiting fits
Puppeteer recommends its locator API for selection and automatic waiting when that model suits your workflow. A locator can be preferable to holding an element handle across a render that replaces nodes. If you need the exact CSS element-screenshot pattern shown above, keep the waitForSelector() and screenshot call together so the handle cannot become stale between unrelated operations. The selection guidance is in Puppeteer page interactions.
What the captured bounds include
Visible pixels only
The result is clipped to the target’s rendered box. Content hidden behind another element is not revealed by the screenshot. If a cookie banner, modal, tooltip, or sticky header covers the target, the covered pixels remain covered.
Scrollable elements
For a scrollable container, the screenshot contains the currently scrolled portion, not every child item in the container. To capture a different portion, scroll that container to the desired position before calling the screenshot method. To capture all content, you need a deliberate stitching or layout strategy; an ordinary element screenshot does not expand a scrollable box automatically.
Elements that are not ready
A selector can match a node that has zero dimensions, is hidden, or is still waiting for data. Wait for visibility and for the state that matters to your output. A fixed timeout may work on one machine and fail on a slower CI runner, so prefer a selector, attribute, or text condition that represents readiness.
Rank #4
- 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
Selector and capture reliability
Handle multiple matches deliberately
A broad selector such as .card may match many elements. Decide whether you want one specific item, every item, or an indexed match. In Playwright, narrow the locator with a user-facing filter or an explicit test ID; in Puppeteer, use a selector that uniquely identifies the intended node before taking the handle. Do not silently accept whichever matching element happens to be returned.
Prevent stale-node failures
Modern frameworks often replace a component after an API response. Resolve the locator as late as possible in Playwright. In Puppeteer, call waitForSelector() immediately before screenshot() and reacquire the handle after any action that can rerender the component. This directly addresses Puppeteer’s detached-element exception.
Control visual variation
- Set a fixed viewport and, when relevant, a fixed device scale factor.
- Use deterministic test data and a stable account state.
- Disable animation or mask regions that legitimately change.
- Wait for images, charts, and fonts according to observable page state.
- Save lossless PNG files for pixel comparisons; choose another format only when file size matters more than exact pixels.
Troubleshooting CSS-selector screenshots
| Symptom | Likely cause | Fix |
|---|---|---|
| Timeout waiting for the selector | The selector is wrong, the page is on a different route, or client rendering has not completed | Inspect the rendered DOM, verify the URL and frame, and wait for the application’s loaded-state marker rather than increasing the timeout blindly. |
| Screenshot is blank or tiny | The element is hidden, has zero dimensions, or its content is injected later | Wait for visibility and a nonzero layout, then capture after the data-bearing child appears. |
| The wrong card is captured | The CSS selector matches several nodes | Use an ID, test ID, role/text filter, or another unique condition; make the selection explicit. |
| Part of the target is missing | An overlay covers it, or the target is a scrollable container | Dismiss or hide the overlay when appropriate, or scroll the container to the desired position before capture. |
| Puppeteer reports a detached element | The framework replaced the node after waitForSelector() |
Resolve the selector again immediately before screenshot(), or use a Puppeteer locator that waits through the update. |
| Images or charts differ between runs | Animation, network timing, random data, or changing timestamps | Wait for a deterministic ready condition, disable animation, and mask or freeze volatile regions. |
| Capture fails only in CI | Different viewport, fonts, browser binaries, authentication, or resource timing | Pin the browser setup, set the viewport explicitly, provide required cookies or headers, and log the URL and selector before capture. |
Local automation versus a hosted screenshot API
Playwright and Puppeteer are appropriate when your process needs browser-level control: authentication flows, clicks before capture, custom scripts, or access to a private network. You own browser installation, concurrency, retries, proxy settings, and cleanup.
A hosted API is useful when a service should return an image from one request. ScreenshotNeo is the first hosted option to try because it removes cookie banners, popups, and chat widgets before capture, bills only clean shots, and has a $5 paid plan for 3,000 shots. It can also capture one element by CSS selector, run custom JavaScript and CSS, wait for a selector or network idle, set headers and cookies, choose device and viewport settings, and return PNG, JPEG, WebP, or PDF. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
Or skip the browser setup
ScreenshotNeo provides the hosted request path at screenshotneo.com. Its API supports CSS-element capture and the other browser options described in the ScreenshotNeo documentation; use the documented parameter for the selector you need.
Best Value
- 【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.
cURL
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}`);
Before returning an image, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and every response reports the result with X-Page-Verdict and X-Billed headers. You can also use full-page capture with lazy images loaded, custom CSS and JavaScript, clicks, request or resource blocking, authorization headers, cookies, user agents, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing gives two months free, and every feature is included on every plan. The API response distinguishes billable clean captures from failures, so you can handle retries using the verdict rather than guessing from an HTTP error alone. Sign up free for 1,000 screenshots a month with no card.
FAQ
Does an element screenshot include the element’s children?
Yes. The capture covers the selected element’s rendered region, including visible descendants, subject to overlays, clipping, and the scroll position of any nested scrollable area.
Should I use a CSS selector in a long-term visual test?
Use CSS when it is an intentional, stable hook. Otherwise, a role, label, text locator, or explicit test ID can better encode the behavior the test is meant to protect and may survive markup refactoring.
Can I capture the same selector at several viewport sizes?
Yes. Create a page or context for each viewport, wait for the same readiness condition, and run the element screenshot in each one. Keep the selector and state setup identical so differences reflect responsive layout rather than timing.
Frequently Asked Questions
Does an element screenshot include the element’s children?
Yes. The capture covers the selected element’s rendered region, including visible descendants, subject to overlays, clipping, and the scroll position of any nested scrollable area.
Should I use a CSS selector in a long-term visual test?
Use CSS when it is an intentional, stable hook. Otherwise, a role, label, text locator, or explicit test ID can better encode the behavior the test is meant to protect and may survive markup refactoring.
Can I capture the same selector at several viewport sizes?
Yes. Create a page or context for each viewport, wait for the same readiness condition, and run the element screenshot in each one. Keep the selector and state setup identical so differences reflect responsive layout rather than timing.
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.

