Use a real browser controlled by Playwright or Puppeteer. Wait for the API response that supplies the content, then wait for a visible page condition confirming that the browser rendered it, and only then take the screenshot. An API response by itself does not prove the updated interface is visible.
How do I take a screenshot after an API call finishes?
In Playwright, start waiting for the relevant response before triggering the action that makes the request. After the response arrives, wait for a locator that represents the result to become visible, then call page.screenshot().
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
// Start listening before the click triggers the API request.
const responsePromise = page.waitForResponse(response =>
response.url().includes('/api/results') &&
response.status() === 200
);
await page.getByRole('button', { name: 'Load results' }).click();
await responsePromise;
// Confirm the API data has reached the rendered interface.
await page.getByTestId('results').waitFor({ state: 'visible' });
await page.screenshot({ path: 'page.png', fullPage: true });
} finally {
await browser.close();
}
Replace the example URL, endpoint fragment, button name, and test ID with values from the target site. The response predicate can be made more specific by checking the request method or other response properties when multiple calls could match. Playwright documents response waits and screenshots in its Page API.
If the API call starts during navigation
When the request happens automatically on page load, arrange the response wait before navigation when practical. Still wait for a meaningful rendered state after the response: client code may need to process the data and update the DOM after the network event completes.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
How do I wait for JavaScript content to load before taking a screenshot?
Wait for evidence of the state you need to capture, not merely for the initial document or a generic page shell. Useful conditions include a results container becoming visible, a loading indicator disappearing, or a known value appearing. The best condition is specific enough that it cannot be satisfied before the intended content is ready.
- Identify the data request. In the page or application, determine which API endpoint supplies the content and whether a click or other action triggers it.
- Arm the response wait first. Create the response promise before clicking or navigating into the action that triggers the request, so a fast response cannot arrive before the listener is active.
- Trigger the request and await its response. Match the endpoint and, where useful, the status or method to avoid treating an unrelated request as the target.
- Wait for the rendered result. Use a meaningful locator or page condition that reflects the expected content.
- Capture only after both checks pass. Use a viewport screenshot for what is currently visible, or a full-page screenshot when the whole document is needed.
Playwright provides waitForResponse, locator waits, and page.screenshot(); Puppeteer provides response and selector/function waits as well. Their APIs are documented in the Playwright Page API and Puppeteer Page API.
Playwright or Puppeteer: which should I use?
For this task, both frameworks support the essential sequence: wait for the relevant response, verify the page state, then capture. Prefer the framework already used by your project and verify its API against the installed package version.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
| Need | Playwright | Puppeteer |
|---|---|---|
| Wait for a response | page.waitForResponse; documented in the Page API. |
page.waitForResponse; documented in the Page API. |
| Confirm rendered state | Locator waits and waitForFunction are available. |
page.waitForSelector and page.waitForFunction are available. |
| Capture a screenshot | page.screenshot(), including full-page capture with fullPage: true. |
page.screenshot(); the screenshots guide also demonstrates element capture. |
| Visual screenshot assertions | Playwright documents screenshot comparisons and their stability behavior in its visual comparisons guide. | Not stated in the cited Puppeteer sources. |
Puppeteer’s screenshot guide shows navigation with networkidle2 followed by a screenshot, and documents ElementHandle.screenshot() for capturing an element. That is an available pattern, not proof that network idleness is always the right signal for a particular page. See the Puppeteer Screenshots guide.
Which readiness condition should I choose?
Known API response
Use a response wait when you can identify the request that provides the data. Match its URL and, when appropriate, method and status. Start waiting before the action that triggers the request.
Visible interface state
Use a locator or function condition to establish that the browser has rendered what the screenshot needs to show. This check complements the response wait: a response may complete before the application has committed its DOM update.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Network idle
Use network idle only if it is meaningful for the site’s behavior. Playwright defines its networkidle navigation state as no network connections for at least 500 ms, but labels it discouraged for testing and advises using web assertions to assess readiness. Pages with polling, analytics, or other background activity may not become idle; conversely, becoming idle does not prove a particular result is displayed. Puppeteer’s networkidle2 screenshot example is not a universal guarantee either.
Fixed delay
A fixed timeout is not tied to whether the request or render has finished. It may expire too soon on a slow run and waste time on a fast one. Use it only when a delay itself is the requirement, not as a substitute for observing readiness.
Choose the screenshot scope and make captures repeatable
Viewport, full page, or element
- Viewport: capture the currently visible browser area when the screenshot is meant to represent the screen as viewed.
- Full page: in Playwright, set
fullPage: trueto capture the full document. - One element: Puppeteer’s
ElementHandle.screenshot()captures a selected element and attempts to scroll a hidden element into view by default.
Choose based on the purpose of the image and ensure the readiness condition refers to the content within that scope. See the Playwright Page API and Puppeteer Screenshots guide.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Visual comparisons
Playwright’s screenshot assertions wait until two consecutive screenshots produce the same result before comparing the last screenshot with the expectation. This can help stabilize a comparison, but does not make output identical across environments. Playwright notes that host operating system, browser version, settings, hardware, power source, headless mode, and other factors can affect rendering. Generate and compare baselines in a consistent environment, and mask or remove volatile regions such as timestamps when appropriate. See Playwright visual comparisons.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common problems and fixes
- The screenshot misses API content. The response wait may be absent, listening too late, or matching the wrong request. Arm it before the triggering action, then wait for a locator that reflects the rendered result.
- The response arrived but the page still looks old. The network event and the DOM update are separate events. Add a UI-state wait after the response rather than capturing immediately.
- The response wait never resolves. Check that the endpoint fragment, method, status, and triggering action match the actual request. If the request starts during navigation, arrange the wait before navigation when practical.
- The network-idle wait hangs or returns too early. Background connections can prevent idleness, and idleness alone does not prove the expected content is visible. Prefer a response wait plus a specific UI condition.
- Captures differ between runs or machines. Keep browser and host environment consistent, and control or mask changing content. Rendering can vary with browser, platform, hardware, settings, and headless mode.
- Full-page or element captures omit what you expected. Confirm the selected capture scope and that the target content is present and visible before taking the screenshot. For Puppeteer element capture, the screenshot API attempts to scroll a hidden element into view by default.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. Its API returns a screenshot or PDF from one GET request, and its parameter names are compatible with those used by other screenshot APIs. The request can wait for a selector, delay, or network idle; use the selector option when the page’s rendered state is the important readiness signal.
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. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. 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 offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.
Free tools Windows power users keep installed
One-click scans. No signup required.
Sign up for 1,000 free screenshots a month with no card.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Frequently Asked Questions
Can a screenshot API response arrive before JavaScript finishes rendering the page?
Yes. The API response can complete before the application processes the data and updates the DOM, which is why a separate rendered-state wait matters.
Does network idle mean every API-loaded element is visible?
No. It indicates network activity has paused according to the framework’s definition, not that a specific interface element has rendered.
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.
Recommended Free Tools

