Query the element and chain Cypress’s .screenshot() command from it:
cy.get('[data-testid="toast"]').screenshot('toast')
The selector should resolve to the one element you intend to capture. If it can match several nodes, narrow it with a more specific selector or .first(). Cypress saves the resulting image under its configured screenshots folder.
Capture one element, step by step
- Give the target a stable selector. A
data-testidor another selector that identifies the component is less brittle than a position-dependent CSS selector. - Put the UI in its final state. Use Cypress commands and assertions to open menus, dismiss loading states, or wait for the content that should appear in the image.
- Query one DOM element. Use
cy.get(); add.first()or a narrower selector if the query could yield multiple matches. - Chain
.screenshot(). Pass a filename when you want a predictable image name.
describe('toast screenshot', () => {
it('captures the visible toast', () => {
cy.visit('/checkout')
cy.get('[data-testid="submit-order"]').click()
cy.get('[data-testid="toast"]')
.should('be.visible')
.screenshot('toast')
})
})
The Cypress API documents element-level screenshots with examples such as cy.get('.post').first().screenshot() and cy.get('[data-testid="toast"]').screenshot('toast'). See the official cy.screenshot() API for the current command signature.
Selectors that reliably target a single node
Use a dedicated test attribute
cy.get('[data-testid="profile-card"]').screenshot('profile-card')
Dedicated test attributes make the intent obvious and avoid coupling a visual test to styling classes. The command receives the element yielded by cy.get().
Recommended Free Tools
#1 Best Overall
- 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
Disambiguate repeated matches
// Capture the first article when several articles are rendered.
cy.get('.post').first().screenshot('first-post')
If the page intentionally renders a collection, decide which member is the visual subject and express that decision in the selector, an index, or a parent-child relationship. Do not rely on an accidental match order when a stable attribute is available.
Make readiness part of the command chain
cy.get('[data-testid="invoice"]')
.should('be.visible')
.and('contain', 'Paid')
.screenshot('paid-invoice')
Assertions establish the state you want before capture. Cypress notes that the screenshot operation is asynchronous and the page can change during the roughly 100 milliseconds before the image is taken, so a screenshot is not an instantaneous snapshot of the command line.
Name the image and add surrounding space
Filename
cy.get('[data-testid="toast"]').screenshot('toast')
The documented forms are cy.screenshot(), cy.screenshot(fileName), cy.screenshot(options), and cy.screenshot(fileName, options). Supplying 'toast' controls the image name within the spec-related output path; omitting it lets Cypress derive a name from the suite and test.
Padding around an element
cy.get('.post').first().screenshot({ padding: 10 })
// CSS-style shorthand is also supported.
cy.get('[data-testid="card"]').screenshot('card', {
padding: [8, 16, 8, 16]
})
padding applies to element screenshots and accepts a number or up to four values using CSS shorthand order (top, right, bottom, left). Use it when the element’s natural bounds are too tight for a report or review.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- 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
Crop a rectangle with clip
cy.screenshot('viewport-region', {
clip: { x: 40, y: 120, width: 640, height: 360 }
})
clip describes a rectangular crop in pixels with x, y, width, and height. Choose it when the desired output is a fixed rectangle rather than the exact bounds of a DOM element. The capture option is ignored for element screenshot captures, so it cannot change the element command into a viewport or full-page capture.
Where Cypress writes the file
By default, Cypress places screenshots in cypress/screenshots. Cypress configuration can change that folder. Paths are built relative to the spec, and a supplied filename replaces the default suite/test-based name. The screenshots and videos guide describes the resulting directory behavior.
If another task needs the exact saved location, use the onAfterScreenshot callback. Cypress provides the saved path and image dimensions to that callback, allowing you to copy, publish, or process the file after capture.
// cypress.config.js
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
// Register your normal events here.
return config
}
}
})
The exact screenshots-folder setting depends on your Cypress configuration style and version; consult the API and guide links above rather than assuming a hard-coded path in a CI script.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- 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.
Element screenshots versus visual regression
.screenshot() writes an image; it does not decide whether that image is correct. Cypress states in its visual-testing documentation: “Cypress does not perform image comparison itself.” If you need baseline comparison, pixel-difference thresholds, approvals, or review history, add a visual-testing plugin or integration designed for that workflow. Keep capture and comparison as separate concerns: first make the element deterministic, then let the comparison system evaluate the saved artifact. See Visual testing in Cypress for the supported approach.
Common failures and precise fixes
The screenshot contains the wrong element
Cause: the selector matched more than one node or a broad ancestor. Fix: inspect the selector in the Cypress runner, add a stable attribute, scope the query to its parent, or use .first() when the first match is explicitly the requirement.
The image shows a loading state
Cause: capture ran before the application reached its final state. Fix: wait through Cypress’s normal command chain for a visible element, expected text, or a completed UI transition, then call .screenshot(). Assertions used before capture establish readiness; assertions chained after the screenshot are not retried by the screenshot command.
The output has no room around the component
Cause: element capture uses the element’s bounds. Fix: set padding, for example { padding: 10 }, or use clip when you need a specifically sized rectangle.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #4
- 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
The file cannot be found in CI
Cause: the test runner’s configured screenshots folder or spec-relative path differs from your local machine. Fix: check the effective Cypress configuration, preserve the screenshots directory as a CI artifact, and use onAfterScreenshot to log the actual path and dimensions.
The screenshot is visually inconsistent between runs
Cause: the page changed during the asynchronous capture window, or animations, time-dependent content, and network data are still active. Fix: arrange deterministic test data, wait for the final state before capture, and disable or settle UI motion through your test setup. The approximately 100 ms timing described by Cypress is a behavior note, not a performance guarantee or benchmark.
You expected Cypress to compare images
Cause: the built-in command only captures. Fix: connect a visual-testing integration that stores baselines and performs comparison; Cypress’s visual-testing guide explains that integrations provide this capability.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Practical patterns
Capture a named component with padding
cy.get('[data-testid="settings-panel"]')
.should('be.visible')
.screenshot('settings-panel', { padding: 12 })
Capture after an interaction
cy.get('[data-testid="user-menu-button"]').click()
cy.get('[data-testid="user-menu"]')
.should('be.visible')
.screenshot('user-menu')
Keep the screenshot command at the end of the chain
Cypress yields the same subject received by the screenshot command, but its documentation cautions that further commands relying on that subject are unsafe to chain afterward. Treat the screenshot as the final action for that queried element; start a new query for subsequent assertions or interactions.
Best Value
- 【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.
Performance, reliability, and maintenance
- Use the smallest useful subject. Element capture avoids producing a full-page image when the review concerns one component.
- Stabilize data before capture. Fixed fixtures and explicit readiness assertions reduce false visual differences.
- Choose names that survive refactors. A semantic filename such as
toast-erroris easier to find than a generated test title. - Separate artifacts from verdicts. Store the image from Cypress, then let a visual-testing integration decide whether it differs from an approved baseline.
- Do not treat timing as a benchmark. Cypress’s roughly 100 ms description explains why a rapidly changing page can differ; it does not promise a fixed capture latency.
Or skip the browser setup
If you need a screenshot service rather than a Cypress-run browser, ScreenshotNeo accepts one GET request and returns PNG, JPEG, WebP, or PDF. It can capture one element by CSS selector and offers custom waits, JavaScript, headers, cookies, device settings, full-page capture, and other controls; see the ScreenshotNeo API documentation for the option names.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request from 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)
And from 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 removes cookie-consent banners, newsletter popups, and chat widgets before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed as clean screenshots, and each response identifies the page verdict and billing result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients, so an AI agent can request captures directly.
The Free plan includes 1,000 screenshots per month without a card. Paid plans start at $5 for 3,000 shots; all features are available on every plan, and yearly billing provides two months free.
Sign up for ScreenshotNeo’s free 1,000-shot plan when you want hosted captures instead of maintaining browser setup.
Frequently Asked Questions
Does Cypress wait for a screenshot assertion to pass?
No. Make readiness assertions before calling .screenshot(); the screenshot command captures the state it reaches and does not retry assertions chained after it.
Is the documented roughly 100 ms capture time a service-level guarantee?
No. Cypress describes it to explain that the page may change during capture. It is not a benchmark or latency guarantee.
Can I use the built-in image as a visual-regression result?
The command supplies the image only. Baseline comparison and review require a separate visual-testing plugin or integration.
The Bottom Line
For a single Cypress element, use a stable one-element query and chain .screenshot(); add a filename, padding, or a rectangular clip only when the output requires it.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteQuick 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.

