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

Use Cypress’s cy.screenshot() command at the exact point in a test where you want an image. You can capture the current viewport, a stitched full page, the Cypress runner, or one DOM element; name files and create subfolders; and let Cypress capture failed tests automatically during cypress run. This guide shows the complete workflow, configuration, reliable capture patterns, troubleshooting, and an API alternative when you need screenshots outside a browser test.

1. Add a manual screenshot to a Cypress test

Call cy.screenshot() after the page has reached the state you need to document. The command can stand alone or be chained from a command that yields an element.

describe('Account page', () => {
  it('captures the signed-in view', () => {
    cy.visit('/account')
    cy.get('[data-cy=account-title]').should('be.visible')
    cy.screenshot('account-page')
  })
})

The optional string is the screenshot name. Without it, Cypress derives a name from the spec, suite, and test. A slash in the name creates a directory beneath the screenshots folder, so cy.screenshot('account/profile') is useful for organizing artifacts.

Capture is asynchronous and takes roughly 100 ms according to the Cypress screenshot API documentation. The DOM can therefore change between issuing the command and the actual image. Treat a screenshot as evidence of the captured state, not an exact instant replay of the command log.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

2. Choose what Cypress captures

Viewport: the visible application area

capture: 'viewport' (the default for a manual screenshot) records the application inside the current browser viewport.

cy.screenshot('checkout-viewport', { capture: 'viewport' })

Use this for a focused UI state such as an open menu, validation message, or modal. Set a consistent viewport before capture when images will be compared later:

cy.viewport(1440, 900)
cy.visit('/checkout')
cy.get('[data-cy=payment-form]').should('be.visible')
cy.screenshot('checkout-desktop')

Full page: scroll and stitch the application

capture: 'fullPage' scrolls through the page and stitches the resulting captures from top to bottom.

cy.visit('/docs/getting-started')
cy.screenshot('getting-started-full', { capture: 'fullPage' })

Long pages can contain sticky headers, lazy content, or animations that change while Cypress scrolls. Wait for important content before invoking the command, and use the same viewport and data each run.

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.

Runner: application plus Cypress Command Log

capture: 'runner' includes the browser viewport and the Cypress runner interface. It is useful when debugging command history, but it is not a clean application image. Automatic failure screenshots are coerced to runner captures.

cy.screenshot('runner-context', { capture: 'runner' })

One element

Chain screenshot() from a command that yields a DOM element to capture that element rather than the whole viewport.

cy.get('.post').first().screenshot('first-post')

Element captures support padding to add space around the element and clip for pixel-based cropping. A clip object uses x, y, width, and height coordinates.

cy.get('[data-cy=invoice]').screenshot('invoice-crop', {
  padding: 16,
  clip: { x: 0, y: 0, width: 900, height: 500 }
})

3. Control names, folders, and duplicate files

Cypress writes screenshots under cypress/screenshots by default. A supplied name replaces the generated test-based name; duplicate names are numbered unless you set overwrite: true.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.
cy.screenshot('smoke/home', { overwrite: true })

Use overwrite only when replacing an artifact is intentional. Otherwise, numbered files preserve every capture from a run. Cypress clears screenshots, videos, and downloads before cypress run by default because trashAssetsBeforeRuns is true. Set it to false in your Cypress configuration when a pipeline must retain assets from earlier runs.

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  trashAssetsBeforeRuns: false,
  e2e: {
    baseUrl: 'http://localhost:3000'
  }
})

Cypress’s example project excludes generated cypress/screenshots/, cypress/videos/, and cypress/downloads/ from source control. Keep them ignored unless your team deliberately stores visual baselines or approved evidence.

4. Capture failed tests automatically

When you run tests with cypress run, Cypress automatically takes a screenshot after a test fails. screenshotOnRunFailure defaults to true; failure files append (failed) to the normal test-based name. This behavior does not occur automatically in cypress open.

npx cypress run

Disable failure screenshots in configuration when they are unnecessary:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  screenshotOnRunFailure: false
})

You can also change the Screenshot API default at runtime:

Cypress.Screenshot.defaults({ screenshotOnRunFailure: false })

Failure captures use runner mode, so the image includes Cypress debugging context rather than only your application.

5. Stabilize captures and protect sensitive data

Wait for the intended state

Assertions are preferable to arbitrary sleeps:

cy.visit('/orders')
cy.get('[data-cy=orders-loaded]').should('be.visible')
cy.get('[data-cy=order-row]').should('have.length', 3)
cy.screenshot('orders-ready')

For content loaded after scrolling, force the page into a deterministic state before a full-page capture. Fix test data, viewport dimensions, locale, and timezone in CI so layout changes do not create unrelated differences.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.

Disable motion during capture

Cypress disables timers and CSS animations by default while taking a screenshot. You can set the option explicitly:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cy.screenshot('stable-modal', {
  disableTimersAndAnimations: true
})

Hide secrets with blackout

Use blackout selectors to cover matching elements, such as account numbers or tokens:

cy.screenshot('redacted-profile', {
  blackout: ['[data-sensitive]', '.api-key']
})

Blackout does not apply to runner captures. Review the resulting image and avoid logging secrets in test output as well.

Use callbacks for temporary DOM changes

onBeforeScreenshot and onAfterScreenshot callbacks can synchronously modify and restore the DOM for non-failure captures.

cy.get('[data-cy=dashboard]').screenshot('dashboard-clean', {
  onBeforeScreenshot($el) {
    $el.find('.live-clock').hide()
  },
  onAfterScreenshot($el) {
    $el.find('.live-clock').show()
  }
})

Keep callbacks synchronous and limit changes to elements that genuinely make the image deterministic.

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

6. A practical capture pattern for visual work

  1. Choose the artifact. Use viewport for a focused state, fullPage for a document-like page, element for a component, and runner for failure diagnostics.
  2. Set the environment. Fix viewport size, seed data, authentication, locale, and relevant feature flags.
  3. Wait on application signals. Assert visible headings, network-driven content, and stable element counts instead of relying only on delays.
  4. Mask or remove volatile content. Apply blackout selectors or a synchronous callback for clocks, avatars, and personal data.
  5. Name predictably. Include the feature and state, such as billing/validation-error.
  6. Run in the same mode in CI. Manual captures and automatic failures are produced by cypress run; interactive cypress open is useful for development but does not create automatic failure images.

cy.screenshot() only creates an image. It does not compare that image with a baseline. Cypress’s visual-testing guidance recommends a separate visual-testing approach when you need pixel or perceptual comparisons.

7. Screenshots versus Cypress video

A screenshot is a single image at one point in a test. Video is a separate artifact that supplies temporal context. Video recording is disabled by default; enable it with video: true. Cypress records one video per spec during cypress run, not during cypress open.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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
// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  video: true
})

Use screenshots for stable evidence or a compact failure attachment; use video when the order and timing of interactions matter.

8. Troubleshooting common screenshot problems

No image appears after a test fails

Confirm you ran npx cypress run, not only cypress open, and check that screenshotOnRunFailure was not disabled. Look under cypress/screenshots in the workspace used by CI.

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

The screenshot shows the wrong state

The command may have run before asynchronous content settled, or the capture’s roughly 100-ms operation allowed the UI to change. Add assertions for the final state, stop animations where appropriate, and remove clocks or random data.

Full-page output is incomplete

Ensure the page has finished loading lazy content before capture. Assert the final content, then call capture: 'fullPage'. Sticky elements and scroll-triggered behavior can produce different results as Cypress stitches sections; redesign the page state or capture a stable element when exact output is required.

Element capture fails or is clipped

Assert that the element is visible and attached, then capture the yielded element directly. Check that custom clip coordinates are in pixels and large enough for the intended region. Use padding instead of an overly tight clip when you only need breathing room.

Files disappear between runs

This is usually the default cleanup behavior. Set trashAssetsBeforeRuns: false if retaining prior assets is required, and verify that your CI job uploads the folder before the workspace is discarded.

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

Sensitive values are visible

Add matching selectors to blackout for application captures, or remove the data before capture. Because blackout is not applied to runner images, avoid runner mode for artifacts that might expose secrets.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

9. Or skip the browser setup

If you need a URL screenshot from a script, build job, or AI workflow rather than from a Cypress test, ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status.

One request returns PNG, JPEG, WebP, or a PDF. See the ScreenshotNeo API documentation for all options.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also supports full-page captures with lazy images loaded, CSS-selector element captures, dark mode, device presets and custom viewports, retina scale, PDF paper and page-range controls, custom CSS and JavaScript, clicks, selector or network-idle waits, ad/tracker/request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

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

The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan, and yearly billing provides two months free. Create a free ScreenshotNeo account to get started.

10. Quick reference

Need Code or setting Result
Current app view cy.screenshot('name') Viewport image
Entire page { capture: 'fullPage' } Scrolled and stitched page
Cypress debugging context { capture: 'runner' } Viewport plus Command Log
One component cy.get(selector).screenshot() Element image
Automatic failure evidence cypress run Runner screenshot when a test fails
Keep previous run assets trashAssetsBeforeRuns: false Do not clear screenshot, video, and download folders first

Frequently Asked Questions

Can Cypress take a screenshot without a test failure?

Yes. Call cy.screenshot() anywhere after the required UI state is ready; automatic failure capture is a separate cypress run feature.

Does Cypress screenshot capture perform visual regression testing?

No. It creates image files. Baseline comparison requires a separate visual-testing solution.

Where are Cypress screenshots saved in a project?

The default directory is cypress/screenshots, unless your project configuration or CI process changes the asset location.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Why is my failure screenshot different from a manual screenshot?

Automatic failure images are coerced to runner mode and include Cypress’s Command Log, while a manual capture may target the viewport, full page, or an element.

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.