To screenshot a page whose content changes through requestAnimationFrame (rAF), first wait for the application state you want to capture, then take the screenshot. An rAF callback runs before a repaint; it does not mean that network requests, fonts, images, or later application updates are finished. For visual-regression testing, Playwright’s toHaveScreenshot() waits for consecutive screenshots to match. For a particular animation frame or chart state, synchronize to an application-defined signal instead.
Why requestAnimationFrame is not a screenshot-ready signal
The browser calls an rAF callback before the next repaint, and the callback is one-shot: an animation must request another frame to continue. Its cadence generally follows the display’s refresh rate, and browsers usually pause it in hidden tabs and iframes. These properties make rAF useful for coordinating animation work with rendering, but a callback alone does not certify that a page is ready to capture. [MDN: requestAnimationFrame()]
A page may still be waiting on data, fonts, image decoding, or another state update after one or more frames. Rather than guessing with a fixed delay, decide what the desired screenshot represents—such as a chart finishing a particular data series or an animation reaching a named progress value—and wait for the application’s signal for that condition.
Capture a known application state with Playwright
Use a real page-level readiness signal, then capture. The example assumes the application sets window.chartReady to true only after the chart has reached the state you want. Replace that predicate with the signal your app actually exposes.
Windows 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 reinstallCrashes, 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 minute#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.
await page.waitForFunction(() => window.chartReady === true);
await page.evaluate(() => new Promise(requestAnimationFrame));
const image = await page.screenshot();
Playwright waits for a promise returned from page evaluation. The extra rAF is useful only if the final state update still needs to pass through a rendering callback; it is not a substitute for the readiness predicate. See the Playwright Page API and the MDN rAF documentation.
When the animation itself is the target
For an exact animation state, synchronize against the application’s own progress or state value, then call page.screenshot(). Do not treat a delay of one or two frames as proof that the animation has reached a particular point. If your app has no observable state yet, add a testable signal, for example an exposed progress value or a flag set when the target state is applied.
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.
Get a stable screenshot for visual regression
When the goal is to compare a page visually rather than capture a specific point in a running animation, use Playwright’s screenshot assertion:
await expect(page).toHaveScreenshot('chart.png');
toHaveScreenshot() waits until two consecutive screenshots match before comparing the result. This stability behavior is distinct from calling page.screenshot() directly. In the Page API, screenshot capture allows animations by default; screenshot assertions document disabled animations as their default. Consult the Playwright PageAssertions API and Page API for the installed version’s options.
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.
Playwright’s screenshot animation option can disable CSS animations, transitions, and Web Animations. Finite animations are fast-forwarded; infinite animations are canceled to their initial state and replayed after capture. That can stabilize a test, but it changes timing and does not freeze JavaScript-driven rAF animation at the precise state you intended. If the page never settles, establish the desired state first or mask the region that is expected to keep changing.
Choose the capture method that matches the output
| Method | What it captures | Selection or permission | Best fit and limitation |
|---|---|---|---|
| Playwright screenshot | A browser-rendered page or element | Automated in the browser context | Automated page or element screenshots and repeatable tests; can wait for app state and use screenshot-specific stability controls. Source. |
Canvas captureStream() |
Canvas contents as a video stream | No display-surface selection; request a frame manually when using a zero frame rate | Useful when the canvas itself is the target, not the surrounding DOM. MDN captureStream() and MDN requestFrame(). |
| Screen Capture API | A user-selected tab, window, or display surface | The browser prompts the user to select what to share | Appropriate for user-authorized sharing or recording, not unattended deterministic page screenshots. MDN: Using the Screen Capture API. |
| html2canvas | An image reconstructed from DOM data | Runs in the page | Convenient for DOM-derived images, but it is not a literal browser screenshot and documents CSS-support and cross-origin image or iframe limitations. Documentation. |
Capture canvas content as a manually requested frame
If the target is only the canvas and a video-stream output is appropriate, use a zero frame rate and explicitly request a frame:
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
const stream = canvas.captureStream(0);
const [track] = stream.getVideoTracks();
track.requestFrame();
This produces a stream of canvas frames, not a screenshot of the whole page. Confirm browser compatibility and that the canvas is origin-clean; MDN documents a SecurityError for a canvas that is not origin-clean. See captureStream() and requestFrame().
Troubleshoot captures that are blank, inconsistent, or stuck
- The screenshot is blank or shows an earlier state: check that the readiness predicate represents the final state, not merely that an animation started. If data or assets load asynchronously, make the application signal readiness only after they are applied.
- The screenshot differs between runs: identify which region or state continues to change. For a regression snapshot, use
toHaveScreenshot(); for a specific animation point, synchronize on its state rather than relying on screenshot stabilization. - The assertion never stabilizes: the page may contain continuously changing content. Set the page to a deterministic state before asserting, or mask the changing region.
- Disabling animations does not freeze the rAF-driven animation: Playwright’s animation controls cover CSS animations, transitions, and Web Animations; they are not a general control for JavaScript animation logic. Set the application’s progress/state explicitly.
- rAF does not seem to run: browsers usually pause callbacks in hidden tabs and iframes. Ensure the relevant page is visible when the code depends on animation frames.
- Canvas capture fails: check whether cross-origin content made the canvas non-origin-clean, which can cause
captureStream()to throwSecurityError.
Or skip the browser setup
ScreenshotNeo provides a one-request screenshot API and an MCP server for AI agents. For dynamic content, use a real app signal in your own browser automation when you need an exact animation state; the API is an alternative when you want a rendered page capture without managing that browser setup. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets. Bot checks, blank pages, and failed loads are never billed; response headers report the page verdict and billing status.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemscURL example (replace the target URL and use your API key):
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.
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. An MCP server lets Claude, Cursor, and other MCP clients use take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. ScreenshotNeo also supports screenshot formats including PNG, JPEG, and WebP, plus PDF. Sign up for 1,000 free screenshots a month—no card required.
FAQ
Does one requestAnimationFrame callback guarantee the browser has painted the final image?
No. It runs before a repaint, but does not establish that asynchronous content or later application state changes are complete.
Can captureStream() take a screenshot of the whole page?
No. It captures canvas content into a video stream; it does not capture the surrounding DOM.
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.

