The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Put await page.waitForSelector() before your screenshot call. For an element image, take the screenshot from the returned element handle; for a full-page image, wait for the element and then call page.screenshot(). Use { visible: true } when the element must be visible, and choose a selector or page condition that signals the content is actually ready—not merely present in the DOM.
Wait for the target, then capture it
This complete example waits for navigation to settle, waits for a visible report element, and saves only that element as a PNG. It closes the browser even if navigation, waiting, or capture fails.
import puppeteer from 'puppeteer';
const url = 'https://example.com/dashboard';
const selector = '#report';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto(url, {
waitUntil: 'networkidle2',
});
const element = await page.waitForSelector(selector, {
visible: true,
timeout: 30_000,
});
if (!element) {
throw new Error(`Element ${selector} was not found at ${url}`);
}
await element.screenshot({ path: 'report.png' });
} catch (error) {
console.error(`Screenshot failed for ${url} (${selector}):`, error);
throw error;
} finally {
await browser.close();
}
Replace the example URL and selector with the page and target you need. The wait belongs immediately before the capture step (or after any navigation that may replace the page content). Puppeteer’s official screenshot guide demonstrates the same element-handle pattern: page.waitForSelector(), followed by the returned handle’s screenshot() method. See the Puppeteer screenshots guide and Page.waitForSelector API.
Choose the right wait condition
Wait for the element to exist
await page.waitForSelector('#report') waits until the selector matches an element in the DOM. If the target already exists, the method resolves immediately. This is appropriate when DOM presence means the content is ready to capture.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors#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
Require visibility
Use { visible: true } when the element must not be hidden with display: none or visibility: hidden. This rules out a hidden match, but it does not prove that the element’s data, images, or internal rendering has finished.
const element = await page.waitForSelector('#report', {
visible: true,
timeout: 30_000,
});
Wait for content readiness, not just visibility
A client-rendered application can create a visible container before it fills in its results. In that case, wait for a more specific marker: a loaded class, a result row, or a non-empty child node that genuinely means the screenshot is ready. You can wait for a marker selector or use page.waitForFunction() for a condition expressed in page JavaScript.
await page.waitForSelector('#report.loaded', {
visible: true,
timeout: 30_000,
});
// Or define a readiness condition that matches the page's own markup:
await page.waitForFunction(() => {
const results = document.querySelector('#report-results');
return results && results.textContent.trim().length > 0;
}, { timeout: 30_000 });
The class and results selector above are examples; use markers that the site actually renders. A condition that merely waits for any text may be wrong for a page where a placeholder message appears before the final data.
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
Use navigation waits as a complement
page.goto() can wait for a navigation milestone such as networkidle2, as in the example. That is a broad navigation heuristic, not proof that a particular application element exists or is ready. A single-page application may finish navigation before it renders the target, so keep the selector-specific wait after navigation when the capture depends on that target.
Free tools Windows power users keep installed
One-click scans. No signup required.
await page.goto(url, { waitUntil: 'networkidle2' });
await page.waitForSelector('#report', { visible: true });
await page.screenshot({ path: 'page.png', fullPage: true });
waitForSelector() is documented to work across navigations. Avoid treating network idle as a substitute for an application-specific readiness condition. The navigation example and selector-wait guidance are in the Puppeteer screenshots guide and waitForSelector API reference.
Capture an element, the page, or a fixed region
| What you need | Wait and capture | What the option controls |
|---|---|---|
| The target element only | const el = await page.waitForSelector('#report', { visible: true }); await el.screenshot({ path: 'report.png' }); |
The element handle’s screenshot captures that element. |
| The whole page after a target is ready | await page.waitForSelector('#report', { visible: true }); await page.screenshot({ path: 'page.png', fullPage: true }); |
The selector is the readiness gate; fullPage: true sets the capture area to the full page. |
| A fixed rectangle | await page.screenshot({ path: 'region.png', clip: { x: 100, y: 200, width: 600, height: 400 } }); |
clip sets a rectangle in page coordinates. Wait for whatever content must appear within it first. |
These capture choices use Puppeteer’s documented screenshot methods and options. Other relevant ScreenshotOptions include type, quality, omitBackground, and captureBeyondViewport; the latter controls whether the clipped area may extend beyond the viewport. Check the ScreenshotOptions reference for option details and constraints, including format-specific behavior.
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.
Set a sensible timeout and handle failure
The documented default timeout for waitForSelector() is 30 seconds. You can set the wait’s own timeout, change the page-wide default using page.setDefaultTimeout(), or set timeout: 0 to disable the timeout. Disabling it means a missing selector can leave the job waiting indefinitely, so it is generally safer to use a finite limit appropriate to the page.
page.setDefaultTimeout(20_000);
const element = await page.waitForSelector('#report', {
visible: true,
timeout: 45_000, // Overrides the page-wide default for this wait.
});
A timeout rejects the wait rather than returning a successful handle. Catch it where you need custom diagnostics or a fallback action. Include the selector and URL in logs; that makes it easier to distinguish a changed page from a generally slow response.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
try {
const element = await page.waitForSelector('#report', {
visible: true,
timeout: 30_000,
});
if (!element) throw new Error('No element handle returned');
await element.screenshot({ path: 'report.png' });
} catch (error) {
console.error(`Could not capture #report at ${url}`, error);
// Optional: capture diagnostic context or take a fallback action here.
throw error;
}
Find the cause when the wait times out
- Selector does not match: Check it against the live page in DevTools. Confirm IDs, classes, escaping, and whether the site changed its markup.
- The element exists but is hidden: With
visible: true, a match hidden bydisplay: noneorvisibility: hiddendoes not satisfy the wait. Confirm the page reached the state that reveals it. - Content arrives after the container: Wait for a result-specific marker or a
waitForFunction()condition that corresponds to complete content, rather than only waiting for the container. - The target is in an iframe: A selector queried in the main page may not find content inside a separate frame. Identify the relevant frame and perform the wait in that frame’s context.
- The target is inside a shadow root: Ordinary page-level CSS queries may not cross a shadow boundary. Puppeteer documents selector syntax for shadow-root combinations; use supported syntax appropriate to the component.
- The page is slow or stalled: Check whether navigation completed, whether the app’s own requests succeeded, and whether the timeout reflects normal load behavior. Increase the timeout only when the page legitimately needs longer; do not use a longer timeout to conceal a selector or readiness-condition error.
The selector API documents CSS selectors and supported text, accessibility role/name, XPath, and shadow-root combinations. Consult the Page.waitForSelector reference for the syntax supported by your installed Puppeteer version.
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
Why fixed sleeps are a poor substitute
A fixed delay such as await new Promise(resolve => setTimeout(resolve, 5000)) does not test whether the target is ready. If the page renders sooner, it wastes time; if it renders later, the screenshot can still race ahead. Prefer a selector or explicit page condition tied to the content you need. A short delay can be useful only when you have a specific reason to pause after a readiness marker—for example, to allow a known visual transition to finish—and it should not replace the readiness check.
Or skip the browser setup
If you need a screenshot endpoint instead of launching and managing Puppeteer, ScreenshotNeo accepts one GET request with a URL and returns a PNG, JPEG, WebP, or PDF. Use this cURL example to save a WebP capture of the page:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/dashboard -o shot.webp
See the ScreenshotNeo documentation for the API. Its capture flow accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. 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 and start with 1,000 free screenshots a month, no card required.
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.
Practical reliability and cost notes
- Keep waits specific: A selector readiness check documents what the screenshot depends on and avoids arbitrary delay. Pick a marker whose meaning remains stable as the page evolves.
- Budget time at the right layer: Navigation can take time before the selector wait begins. Set finite limits and log which stage failed so a slow navigation is not confused with missing content.
- Reuse browsers carefully in batch jobs: For repeated captures, browser startup and page lifecycle affect total runtime. Reusing a browser can avoid repeated launches, but isolate pages and close them reliably; always close the browser when the job or worker ends.
- Control capture scope: An element screenshot is generally the most direct choice for one component. Full-page and high-resolution captures can produce larger outputs and take more work to render and transfer; use them only when the output requires them.
- Make failures observable: Record the URL, selector or readiness condition, elapsed time, and error. Avoid silently saving a screenshot after a failed wait, since that can make an incomplete page look like a valid result.
FAQ
Does waitForSelector throw if the element is already on the page?
No. It resolves immediately when the selector already matches and the requested conditions are satisfied.
Can I wait for an element and still save a full-page screenshot?
Yes. Await the selector first, then call page.screenshot({ fullPage: true }); the wait and the capture area are separate choices.
Does visible: true mean the element’s data is finished loading?
No. It checks visibility, not application-specific data readiness. Wait for a meaningful content marker or condition when the target fills in asynchronously.
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.

