Use await page.waitForSelector() before the screenshot call. Pass { visible: true } when the target must be visible; then use page.screenshot() for the page or the returned element handle’s screenshot() method for an image of just that element.
Wait for the readiness condition you actually need
waitForSelector() resolves immediately if the selector already matches. Otherwise it waits for a matching element to appear, subject to its timeout. With no options, it checks for DOM presence; it does not require that the element be visible.
As an Amazon Associate I earn from qualifying purchases.
const element = await page.waitForSelector('#target', {
visible: true,
timeout: 10_000,
});
if (!element) {
throw new Error('Target element was not found');
}
await page.screenshot({ path: 'page.png' });
// To capture only the selected node instead:
// await element.screenshot({ path: 'element.png' });
The visible: true option requires a matching element that is not hidden by display: none or visibility: hidden. Visibility does not prove that content inside the element has finished loading, that an animation has ended, or that its images and fonts are ready. For those cases, wait for an application-specific readiness signal as well.
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 minuteChoose among presence, visibility, hidden state, and custom readiness
- Element exists:
await page.waitForSelector('#target')waits for a matching node to enter the DOM. - Element is visible:
await page.waitForSelector('#target', { visible: true })waits for a match that is not hidden with the CSS properties described above. - Element is hidden or removed:
await page.waitForSelector('.loading', { hidden: true })waits for the selector to be absent or hidden. Use this for a loading overlay, not as a substitute for waiting for the screenshot target. - Application-specific state: use
page.waitForFunction()if readiness depends on a flag or attribute rather than selector presence. Its function is reevaluated until it returns a truthy value.
await page.waitForFunction(() => {
const target = document.querySelector('#target');
return target?.getAttribute('data-state') === 'loaded';
});
await page.screenshot({ path: 'page.png' });
Choose a condition the page can reliably signal. There is no universal Puppeteer wait that proves every site is ready for a perfect screenshot.
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Choose a page screenshot or an element screenshot
Use page.screenshot() when the output should show the page. Keep the ElementHandle returned by waitForSelector() and call its screenshot() method when the output should contain only that node. Puppeteer’s element screenshot method attempts to scroll the element into view if needed.
const element = await page.waitForSelector('.price-card', {
visible: true,
});
if (!element) throw new Error('Price card was not found');
await element.screenshot({ path: 'price-card.png' });
Set a timeout and decide how failure should behave
Puppeteer documents a default selector-wait timeout of 30,000 milliseconds. Set timeout for an individual wait, change the page default with page.setDefaultTimeout(), or pass timeout: 0 to disable the timeout. A non-hidden wait that does not find a match before its timeout throws an error.
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
try {
const element = await page.waitForSelector('#target', {
visible: true,
timeout: 10_000,
});
if (!element) throw new Error('Target was not found');
await page.screenshot({ path: 'page.png' });
} catch (error) {
console.error('Could not capture a ready page:', error);
throw error; // or record the failure and continue, as appropriate
}
The wait options also accept a cancellation signal. Avoid disabling the timeout unless the surrounding workflow has another way to stop a stuck capture.
Recommended Free Tools
Combine selector readiness with navigation when needed
Navigation completion and target readiness are separate checks. If the page navigates before rendering the target, await the navigation lifecycle condition and then the selector. Puppeteer’s screenshot guide demonstrates waiting for networkidle2 during navigation; that alone does not establish that a particular target exists or is ready.
Rank #3
- 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
- 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
- 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
await Promise.all([
page.waitForNavigation({ waitUntil: 'networkidle2' }),
page.click('a.next-page'),
]);
await page.waitForSelector('#target', { visible: true });
await page.screenshot({ path: 'page.png' });
If the page exposes an explicit loaded state, check that state too rather than treating network idleness or visibility as proof that every asynchronous task is complete.
Wait for a selector inside a frame
A selector wait on page addresses the page’s main frame. If the target belongs to an iframe, call waitForSelector() on that frame instead. The Frame API documents selector waits across navigations.
Rank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
const frame = page.frames().find(frame => frame.url().includes('widget'));
if (!frame) throw new Error('Widget frame was not found');
const element = await frame.waitForSelector('.widget-ready', {
visible: true,
timeout: 10_000,
});
if (!element) throw new Error('Widget target was not found');
await page.screenshot({ path: 'page.png' });
Use a frame-identification condition appropriate to your page; the URL check above is only an example. A page screenshot captures the rendered page, while the frame-specific wait ensures the target is found in the intended frame.
Use a locator when you need more than a low-level wait
Puppeteer describes locators as its recommended API for selecting and interacting with elements. They automatically wait for presence and an appropriate state. A locator’s wait() method is useful when you only need to wait for its element state; waitForSelector() remains a documented lower-level option when you want a direct selector wait and an ElementHandle.
Best Value
- Compatible with Nintendo Switch 2’s new GameChat mode
- HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
- Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
- Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
- Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video
Troubleshoot waits that time out or capture too early
- The selector times out: confirm the selector matches the page’s actual DOM, the page reached the expected route, and the target is in the frame you are checking. Increase the timeout only if the page legitimately needs more time.
- The selector matches but the target is not visible: use
{ visible: true }if visibility is required, and check whether the site hides the element until another action or state change. - The screenshot still shows incomplete content: selector presence or CSS visibility is not an application-ready signal. Wait for a meaningful state, such as a loaded attribute, with
waitForFunction(). - A hidden-state wait completes unexpectedly:
{ hidden: true }can resolve because the node is absent. Use it for disappearance conditions; use a normal or visible wait for a target you need to capture. - The capture hangs: the normal wait has a 30-second default timeout; set a suitable per-call timeout or page default. Passing
timeout: 0removes that safeguard. - The element is in an iframe: locate the frame and wait through its Frame API, rather than querying only the main page.
- The page navigates during the workflow: coordinate navigation and target readiness separately, for example by awaiting navigation and then waiting for the target selector.
Or skip the browser setup
ScreenshotNeo can wait for a CSS selector before capturing; its API also supports a selector wait, delay, or network-idle wait. Here is a one-request capture:
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 API documentation for request options. ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; these steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Frequently Asked Questions
What is Puppeteer’s default waitForSelector timeout?
30,000 milliseconds.
Does visible: true wait for images and fonts to finish loading?
No. It checks visibility, not completion of asynchronous content or assets; wait for a suitable application-specific readiness signal when needed.
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.




