Crashes, 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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallUse Playwright’s locator API: identify the element with page.locator() (or another locator strategy), then call locator.screenshot(). Playwright checks that the element is actionable, scrolls it into view, clips the image to its box, and returns a Buffer. Add path to save the image; otherwise, process the returned bytes in memory.
Minimal working example
Install Playwright, launch a browser, navigate to a page, and capture the matching element:
import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.locator('h1').screenshot({ path: 'heading.png' });
await browser.close();
The filename extension determines the format. PNG is the default when no other format is selected. If you omit path, the method returns an image buffer:
const image = await page.getByRole('img', { name: 'Product photo' }).screenshot();
// image is a Node.js Buffer
await fs.promises.writeFile('product.png', image);
Use locator.screenshot() in current code. Playwright marks the older elementHandle.screenshot() API as discouraged and recommends locators instead.
#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
Choose a reliable locator
A screenshot is only as reliable as the locator that identifies its target. Prefer locators that describe user-visible meaning, then stable test identifiers, and use CSS selectors when you control the markup.
Role and accessible name
await page.getByRole('button', { name: 'Buy now' }).screenshot({ path: 'buy-button.png' });
Label, text, or placeholder
await page.getByLabel('Email address').screenshot({ path: 'email-field.png' });
await page.getByText('Total').screenshot({ path: 'total.png' });
Test ID
await page.getByTestId('profile-card').screenshot({ path: 'profile-card.png' });
CSS selector
await page.locator('.header').screenshot({ path: 'header.png' });
If a selector matches multiple elements, Playwright’s strictness rules can fail the operation. Narrow it with a more specific locator or an explicit index:
await page.locator('.card').nth(1).screenshot({ path: 'second-card.png' });
An index is appropriate only when order is meaningful; otherwise add a distinguishing attribute or accessible name.
What the capture includes—and what it does not
- The image is clipped to the position and size of the matched element, not the whole page.
- Playwright waits for actionability checks and scrolls the element into view before capturing.
- If another element covers the target, that obstruction remains visible in the screenshot.
- For a scrollable container, only the content at its current scroll position appears. The method does not automatically stitch every scroll position.
- If the element is detached from the DOM during capture, Playwright throws an error.
These rules matter for sticky headers, modals, virtualized lists, carousels, and lazy-rendered components. Scroll the container yourself, close or hide overlays, or wait for the component’s final state before calling screenshot().
Recommended Free Tools
Control timing and dynamic content
Locators wait for actionability, but they do not know whether an animation, data refresh, or rotating advertisement is visually finished. Wait for a meaningful UI condition rather than adding an arbitrary sleep:
const card = page.getByTestId('result-card');
await card.waitFor({ state: 'visible' });
await expect(card).toContainText('Complete');
await card.screenshot({ path: 'result.png' });
For repeatable captures, disable motion during the operation:
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
await card.screenshot({
path: 'result-stable.png',
animations: 'disabled'
});
With animations disabled, finite animations are fast-forwarded to completion. Infinite animations are canceled to their initial state for the capture and resumed afterward. Confirm option names against the Playwright version installed in your project because the API is version-sensitive.
Inject capture-only CSS
await card.screenshot({
path: 'no-caret.png',
style: `* { caret-color: transparent !important; }`
});
The style option injects CSS for this capture. It is useful for hiding blinking carets, timestamps, cursors, or other purely visual noise without changing application code.
Mask sensitive or unstable regions
await card.screenshot({
path: 'masked.png',
mask: [page.locator('.avatar'), page.locator('.live-price')],
maskColor: '#888888'
});
Masking covers selected locator regions. It does not remove the elements from the DOM or alter layout.
Output format, scale, and quality
| Choice | How to set it | When to use it |
|---|---|---|
| PNG | path: 'capture.png' |
Lossless output and the default format. |
| JPEG | path: 'capture.jpg', quality: 80 |
Smaller photographic images; quality applies to JPEG. |
| WebP | path: 'capture.webp', quality: 80 |
Compact output when your downstream tools support WebP. |
| CSS scale | scale: 'css' |
One output pixel per CSS pixel. |
| Device scale | scale: 'device' |
Device-pixel output; high-DPI contexts create larger files. |
Transparent backgrounds are supported for formats that support transparency, but not for JPEG. Set the browser context or page viewport before capture when exact dimensions matter. JPEG and WebP quality settings have no effect on PNG.
Capture a component after interaction
Many elements appear only after a click, hover, or selection. Perform the interaction through a locator, wait for the resulting state, then capture:
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 menu = page.getByRole('menu');
await page.getByRole('button', { name: 'Options' }).click();
await menu.waitFor({ state: 'visible' });
await menu.screenshot({ path: 'options-menu.png', animations: 'disabled' });
If a cookie banner, chat widget, or another overlay covers the component, dismiss it explicitly or hide it with capture-specific CSS. Playwright will not remove overlays automatically.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Screenshot versus screenshot assertion
locator.screenshot() is a capture operation: it saves or returns an image. A screenshot assertion is a test-runner feature that waits until two consecutive locator screenshots are identical and compares the final image with an expectation. Assertions therefore belong in Playwright Test, not in a standalone browser script:
import { test, expect } from '@playwright/test';
test('card matches its baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page.getByTestId('result-card')).toHaveScreenshot('result-card.png');
});
Use a normal screenshot when you need an artifact for a report, email, or pipeline. Use an assertion when you need a pass/fail visual regression check.
Complete reusable helper
import { chromium } from 'playwright';
export async function screenshotElement(url, selector, outputPath) {
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(url, { waitUntil: 'networkidle' });
const target = page.locator(selector);
await target.waitFor({ state: 'visible' });
await target.screenshot({
path: outputPath,
animations: 'disabled',
scale: 'css'
});
} finally {
await browser.close();
}
}
await screenshotElement(
'https://example.com',
'[data-testid="result-card"]',
'result-card.png'
);
In production, prefer a project-specific readiness signal over networkidle when the site maintains analytics, WebSockets, or polling requests. Set an explicit timeout appropriate to your page and log the URL, locator, viewport, and browser version alongside failures.
Troubleshooting common failures
“Locator resolved to multiple elements”
Your locator is ambiguous. Add a role name, test ID, filter, or nth(). Verify that the chosen element is the one a user would recognize.
Timeout waiting for the element
The element may be hidden, inside a frame, rendered only after interaction, or absent at that URL. Wait for the correct state, perform the required click, or switch to the frame locator that owns the 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
The screenshot shows an overlay
Occlusion is expected behavior. Dismiss the overlay, click its close control, or inject a narrowly scoped style rule. Do not assume a locator screenshot cleans the page.
Only part of a long list is visible
The target is a scroll container. Capture the currently visible state, scroll and capture additional regions, or redesign the page for a full-page capture. A single element screenshot does not automatically stitch internal scrolling.
The image changes between runs
Control viewport, fonts, locale, timezone, data, caret, animations, and network responses. Disable animations, mask timestamps or live values, and wait for a deterministic state before capture.
“Element is not attached to the DOM”
A framework replaced the node while Playwright was capturing it. Reacquire the locator after the UI settles, wait for a stable state, and avoid retaining an obsolete element handle.
The file is unexpectedly large or blurry
Check scale and format. Device scale on a high-DPI context increases dimensions; JPEG/WebP quality trades size for detail. Use CSS scale for predictable pixel dimensions and PNG for sharp UI text.
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.
Performance, reliability, and cost considerations
- Reuse a browser process for many captures, while creating isolated contexts when cookies or viewport settings must differ.
- Capture only the locator you need; it transfers and stores less data than a full-page image.
- Wait on application signals instead of long fixed delays to reduce idle time without making captures flaky.
- Keep browser, OS fonts, viewport, and device scale consistent for visual comparisons.
- Save buffers directly to object storage or a test artifact system when local files are temporary.
Playwright itself runs in your environment, so infrastructure cost depends on your browser workers, CPU, memory, storage, and concurrency. There is no special per-element API charge in the method described here.
Or skip the browser setup
For a hosted screenshot of a URL, ScreenshotNeo provides a single API call and can return PNG, JPEG, WebP, or PDF. It is useful when you do not want to maintain Playwright browsers, fonts, workers, and navigation code.
Free tools Windows power users keep installed
One-click scans. No signup required.
See the parameter reference in the ScreenshotNeo documentation. 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}`);
ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; 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 result. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes the features; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Frequently Asked Questions
Can I screenshot an element inside an iframe?
Yes. Obtain the owning frame with a frame locator, then locate the element within that frame and call its screenshot method.
Does locator.screenshot() capture an element’s hidden overflow?
No. It captures what is visible in the element’s current rendered box; content clipped by a scroll container is not automatically stitched.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Which Playwright option stops blinking UI during capture?
Use animations: 'disabled', and use style or mask for other unstable visual regions.
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.

