Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Wait for Images and Fonts Before a Cypress Screenshot

A reliable Cypress screenshot starts with an app-state assertion, successful checks for the images that matter, and a wait for document.fonts.ready.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before calling cy.screenshot(), wait for the application to show the state you intend to capture, verify that screenshot-critical images loaded successfully, and wait for document.fonts.ready. Cypress’s screenshot command does not itself guarantee that app data or visual assets have settled.

Wait for the page state, images, and fonts

Put readiness checks before the screenshot command. Cypress retries assertions chained from queries, so an assertion on image success is more dependable than an arbitrary delay.

As an Amazon Associate I earn from qualifying purchases.

cy.contains('h1', 'Ready').should('be.visible')

// Scope this to images that must appear in the screenshot.
cy.get('[data-screenshot-image]').should(($imgs) => {
  [...$imgs].forEach((img) => {
    expect(img.naturalWidth).to.be.greaterThan(0)
  })
})

cy.document().then((doc) => doc.fonts.ready)
cy.screenshot('stable-page')

The heading assertion is an example of an app-owned signal: replace it with a visible condition that means your intended UI is ready, such as a loaded-results heading or a completed-state label. The image selector is likewise illustrative; mark or select the images that matter to the capture.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why wait for each kind of readiness?

  • Application state: An image or font check cannot prove that data-driven rendering, client-side updates, or a transition has finished. Assert the user-visible state you expect to capture.
  • Images: For targeted <img> elements, naturalWidth > 0 is a useful success condition. complete alone is not enough: it can be true for a broken image or an image with no source.
  • Fonts: document.fonts.ready resolves after the document has completed loading fonts and associated layout operations, with no further font loads needed for that state. It does not establish that the intended font was available or loaded successfully.

cy.document() yields the active page document, and Cypress waits for a promise returned from a .then() callback before continuing. That is why returning doc.fonts.ready pauses the command chain before the screenshot.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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

Handle empty image sets and lazy loading

cy.get() expects at least one match. If a page can legitimately have no screenshot-critical images, make the expected count explicit or use a helper that handles an empty set. Otherwise, the test may fail because there were no matches rather than because an image failed.

Lazy images may not load until they approach the viewport. For a partial-page capture, limit the check to images in the relevant region and cause those images to be requested—for example, scroll them into view—before asserting success. For a full-page capture, account for the images that the capture actually needs; do not force every offscreen image to load when it is outside the intended capture.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • 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

What these checks do not cover

  • CSS background images: The <img> selector does not verify them. Add an app-owned readiness signal or a check for the specific background resource if it affects the screenshot.
  • Canvas and video: Canvas drawing and video frames have their own readiness conditions. Wait on signals from the code that renders or supplies them.
  • Font identity: A resolved font promise is not proof that a particular webfont was used. Confirm the app’s font CSS and font files are present in the test environment, and investigate failed resource requests if the typography looks wrong.

These checks follow the scope of the browser image-element API and Cypress’s guidance to capture only after the page has stopped changing; they are not a universal asset barrier for every rendered content type.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why Cypress screenshot options are not a substitute

cy.screenshot() is asynchronous, and the page can change between issuing the command and the actual capture. Cypress recommends confirming that the page is done changing before taking a snapshot. Put the state and asset waits first; do not assume the screenshot command will wait for application data, images, or fonts.

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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.

Screenshot options and callbacks can affect capture behavior or synchronously adjust the DOM, but they do not replace readiness checks. Likewise, Cypress’s waitForAnimations and animationDistanceThreshold apply to action commands such as clicks; they do not globally stop all motion before a screenshot. Disable or finish the relevant animations in the test environment if they alter the captured frame.

Keep visual captures reproducible

Even a fully loaded page can produce different pixels when the rendering environment changes. Cypress identifies operating system, browser, scaling, and installed fonts as factors in visual comparisons. Keep those conditions consistent between baseline and comparison runs, and treat asset readiness as one part of screenshot stability rather than a guarantee of pixel-identical output.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The image assertion fails

Check that the selector targets the intended image, that the app has assigned its source, and that the image request succeeded. If it is lazy-loaded, bring it into the relevant capture region before asserting. A failed image should cause the test to fail clearly rather than silently record a blank or fallback image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The test fails because no image matched

Decide whether an empty set is valid for that page. If it is, handle the empty set explicitly; if it is not, retain the query failure because it may reveal that expected content never rendered.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.

The font promise resolves, but typography is wrong

Inspect whether the test environment loads the application’s font styles and files and whether the intended font resource request succeeds. Font readiness means no more font loading is needed for the current document state, not that a specific face was selected.

The screenshot still catches a transition or changing content

Strengthen the app-state assertion to represent the exact state to capture. Then disable or complete the animation that affects the screenshot; action-command animation waits do not freeze unrelated motion across the page.

Or skip the browser setup

If your goal is to capture a URL rather than assert Cypress-rendered application behavior, ScreenshotNeo provides a screenshot API and MCP server. It accepts a URL in one GET request and can return PNG, JPEG, WebP, or PDF. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for AI agents and other MCP clients. See the API documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The request returns an image or PDF for a URL; it does not replace Cypress assertions for application state in your own test. ScreenshotNeo includes 1,000 screenshots a month free with no card, and paid plans start at $5 for 3,000. Sign up for free.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.