Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →To screenshot one element selected by CSS, locate it in your browser automation script and call the element’s screenshot method. In Playwright, use page.locator('.target').screenshot({ path: 'element.png' }); in Puppeteer, select the element and call its screenshot() method. The image is clipped to the element’s rendered region, not the whole page.
Capture an element with Playwright
Playwright’s page.locator() accepts CSS selectors. Call screenshot() on the locator to save an image of the matched element:
const target = page.locator('.target');
await target.screenshot({ path: 'element.png' });
For example, with a page already open in a Playwright script:
await page.goto('https://example.com');
await page.locator('.target').screenshot({ path: 'element.png' });
Replace .target with a selector for the element you want. The screenshot is clipped to that element’s position and dimensions. See the Playwright locator screenshot documentation for the API details.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Choose a selector that identifies the intended element
If a selector matches repeated components, make sure you are capturing the right one. For example, a page may contain several .card elements. Refine the selector or choose the intended match explicitly. A locator is useful when the page may re-render: Playwright documents that a locator can resolve the matching element again after DOM changes, unlike a handle tied to a particular element. See Playwright locators.
Capture an element with Puppeteer
In Puppeteer, select the element and call screenshot() on its ElementHandle:
Rank #2
const element = await page.$('.target');
if (!element) {
throw new Error('No element matched .target');
}
await element.screenshot({ path: 'element.png' });
The explicit missing-element check prevents the script from proceeding as if a capture succeeded when the selector matched nothing. Puppeteer’s element screenshot method scrolls the element into view if needed, then captures it using the page screenshot machinery. See the Puppeteer screenshot guide.
Make the capture reflect the state you need
A selector identifies a DOM element; it does not guarantee that the page has finished rendering the content you want. Navigate, wait for the target or relevant content to appear, and capture only when the page is in the intended state. There is no universal readiness condition for every site, so choose a condition appropriate to the page and workflow.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
- Confirm the match. If the page has repeated elements, verify your selector targets the intended one.
- Check visibility. A target covered by another element can be obscured in the screenshot. For Playwright, an overlay can hide the target even though the locator matches it.
- Account for page changes. When the DOM may replace an element during rendering, locator-based targeting in Playwright can re-resolve the match.
- Check the installed version. API signatures and defaults can vary; consult documentation for the version in your project.
Troubleshoot blank, wrong, or partial captures
| Symptom | Likely cause | What to check |
|---|---|---|
| No image or a selector error | The selector did not match an element, or the target was not present yet. | Check the selector against the current DOM and wait for the target state your page requires. |
| The wrong repeated component appears | The selector matches multiple elements. | Refine the selector or explicitly select the intended match. |
| The image is blank or obscured | An overlay or another element covers the target. | Inspect the page at capture time and address the covering element if appropriate. |
| The capture is partial or content is missing | The page or target content may not have reached the desired state before capture. | Wait for the relevant content or state rather than assuming navigation alone means it is ready. |
| Element is outside the viewport | Capture behavior differs by library. | Puppeteer documents scrolling the element into view for its element screenshot method. Check the installed library’s documentation for the workflow you use. |
Choose Playwright or Puppeteer based on your workflow
Both libraries document element-level screenshots. Prefer the automation library already used in your project. Playwright offers locator-based targeting that can resolve again after DOM changes; Puppeteer’s documented element screenshot behavior includes scrolling the target into view when needed. The cited API documentation does not establish a speed or image-fidelity winner.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo can capture a page through one GET request, including an element selected by CSS. Cookie banners are accepted and removed before capture along with 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides screenshot tools for AI agents, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000.
For selector options and the API details, see the ScreenshotNeo documentation.
Rank #4
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com --data-urlencode selector=.target -o shot.webp
Visit ScreenshotNeo for the service details, or sign up free for 1,000 screenshots a month with no card.
Quick Recap
Best Value
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.




