Use locator.screenshot() to capture an element’s rendered bounds, or page.screenshot({ clip: ... }) to capture a rectangle defined by coordinates. Choose the first when the target is a page element that can be selected; choose the second when the crop is defined by a fixed position and size.
Choose an element crop or a coordinate crop
“Area screenshot” can mean two different things in Playwright. An element screenshot uses a locator and captures that element’s bounds. A clipped page screenshot uses a rectangle whose top-left position and dimensions you specify. They are not interchangeable: a locator follows the matched element when the layout changes, while a clip stays tied to the coordinates you give it.
| Need | Use | What defines the captured area |
|---|---|---|
| Capture a particular heading, card, chart, or other page element | locator.screenshot() |
The bounds of the matched element |
| Capture a particular region regardless of which element is there | page.screenshot({ clip }) |
The rectangle’s x, y, width, and height |
| Capture the full scrollable document | page.screenshot({ fullPage: true }) |
The full page, rather than an area crop |
For an element whose location may shift as the page changes, use a locator. For a crop that must cover the same viewport coordinates each time, use clip. If you need the entire scrollable document, use full-page capture instead of trying to enlarge an area crop.
Capture a DOM element with a locator
Here is a complete JavaScript example using Playwright’s locator API. It opens a page, locates a heading by its accessible role and name, and writes the screenshot to a PNG file:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →#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
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
try {
await page.goto('https://example.com');
await page.getByRole('heading', { name: 'Example Domain' }).screenshot({
path: 'heading.png',
});
} finally {
await browser.close();
}
})();
Replace the example URL and heading name with the page and accessible heading in your application. The target has to resolve to an attached element. The locator screenshot method waits for actionability and scrolls the element into view before capture. If the element detaches during the operation, the method throws rather than producing the requested element screenshot.
You can use other locator strategies when they better identify the target. For example, a stable CSS selector can target a component:
await page.locator('.report-card').screenshot({
path: 'report-card.png',
});
A selector should identify the element you mean, not merely an element that happens to occupy its current coordinates. If the page contains more than one match, make the locator specific enough to select the intended target. With a role-and-name locator, use the accessible role and name appropriate to the actual page; with a CSS locator, use a selector that remains meaningful as the layout changes.
Capture an arbitrary rectangle with clip
Use page.screenshot() with a clip object when you know the desired rectangle’s coordinates and dimensions:
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
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
try {
await page.goto('https://example.com');
await page.screenshot({
path: 'region.png',
clip: { x: 100, y: 120, width: 400, height: 250 },
});
} finally {
await browser.close();
}
})();
In this example, x and y set the clip rectangle’s top-left position, and width and height set its dimensions. Change those values to fit the area you need. Unlike a locator screenshot, this does not identify a DOM element: if a responsive layout moves the content, the same coordinates may capture a different part of the page.
Save the image or use it in memory
Providing path writes the image to that location. If you omit path, a screenshot method returns image data; the locator screenshot method returns a buffer. That lets a test pass the bytes to another part of its workflow instead of writing a file at capture time:
const imageBuffer = await page.locator('.report-card').screenshot();
Use the full-page option for an entire scrollable page rather than a crop:
await page.screenshot({
path: 'full-page.png',
fullPage: true,
});
Full-page capture changes the capture scope; it is not another way to specify the bounds of a selected element.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.
Make captures more repeatable
Screenshot output can be affected by what the page is doing at capture time. Playwright’s locator screenshot options document animation control, caret handling, locator masks, styles, and transparent backgrounds where supported. For repeatable captures, consider disabling animations or using the documented style and mask options to handle dynamic or sensitive regions. Check the API documentation for the Playwright version installed in your project: the current screenshots guide is under /docs/next/, and available options can evolve between releases.
- Dynamic content: Decide whether changing content should remain visible or be masked. A mask can help distinguish a stable layout from a changing value, but it does not make that value part of the captured page deterministic.
- Animation: If a transition affects the desired frame, use the documented animation control rather than assuming the screenshot will always show the same animation state.
- Covered elements: Scrolling a locator into view does not guarantee that no other element covers it. Check the resulting screenshot if an overlay or other page content may obscure the target.
- Scrollable elements: A locator screenshot captures the element’s bounds, not every item in an element’s scrollable contents. Only the content currently scrolled into view appears.
Troubleshoot the crop
The locator screenshot throws because the target is missing or detached
The locator must resolve to an attached element. Check the locator’s role, accessible name, or selector against the page you opened. If the element is removed while Playwright is capturing it, the call throws; arrange the capture when the target is present and stable enough for the operation to complete.
The screenshot shows the wrong part of the page
First check which approach you used. A locator takes the matched element’s bounds; a clip uses the rectangle values you supplied. If you chose clip, verify each coordinate and dimension against the intended region. If the page layout can move or reflow, use a locator for the relevant element instead of relying on fixed coordinates.
The element is in the screenshot but not visibly unobstructed
A locator screenshot scrolls the target into view, but content over it can still affect what the image shows. Inspect whether a banner, overlay, or other element covers the target. Scrolling into view should not be mistaken for a guarantee that the element is unobstructed.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsA scrollable panel appears incomplete
That is expected for an element screenshot: it captures the element’s bounds, and only the panel content currently scrolled into view appears. If you need a different portion of the panel, position the panel’s scroll before capturing. If you instead need the full scrollable document, use fullPage: true on the page screenshot; that option is for the page, not a guarantee of capturing all content inside a nested scrollable element.
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
Options shown in an example are unavailable in your project
Confirm the installed Playwright version and consult its documentation. Screenshot options change over time, and the screenshots guide under /docs/next/ may describe the next documentation version rather than the exact release installed in your project. Do not assume an option documented for another version is available in your environment.
When to use Playwright and when to use a screenshot API
Playwright is the direct choice when your capture belongs in browser automation and depends on the page state your code has opened. Its locator and clip methods let you express an element-bounds capture or a coordinate-defined crop. If you only need a screenshot of a URL and prefer not to set up browser capture code, a hosted screenshot API is a different workflow; it does not replace a Playwright test that needs its own browser session and page state.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
For a URL-based capture, ScreenshotNeo provides a screenshot API and MCP server. Its CSS-selector capture can target an element on a page, while the Playwright examples above remain the better fit when the capture must come from the browser session your test controls.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
One GET request returns an image or PDF. For example, this cURL request saves a WebP screenshot of Stripe; replace the URL with the page you want to capture:
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 -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 API parameters and response details. Cookie banners are accepted before capture and more than 60 known consent platforms, newsletter popups, and chat widgets are removed; each step can be turned off. Bot checks, blank pages, and failed loads are never billed. The response includes X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Can I take an element screenshot without saving a file?
Yes. Omit the path option and use the returned image buffer in your test or application.
Recommended Free Tools
Should I use ElementHandle.screenshot() for a new implementation?
No. Playwright discourages that method and recommends the locator-based locator.screenshot() API.
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.

