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

Query the element, make sure the selector resolves to one DOM node, and chain Cypress’s .screenshot() command:

cy.get('[data-testid="toast"]').screenshot('toast')

The first argument is the image name. If a selector can match several nodes, narrow it with a more specific selector or .first() before taking the screenshot. Cypress documents this element-level pattern in its cy.screenshot() API reference.

Capture one element

A Cypress element screenshot starts with a command that yields a DOM element, such as cy.get(), and ends with .screenshot(). The command captures the selected element’s rendered bounds rather than the entire viewport.

describe('toast screenshot', () => {
  it('captures the toast notification', () => {
    cy.visit('/checkout')
    cy.get('[data-testid="toast"]').screenshot('toast')
  })
})

Use a stable test attribute when possible. A class used for styling may change; a dedicated data-testid makes the capture target explicit. Cypress also supports a selector followed by .first() when the intended target is the first match:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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
cy.get('.post').first().screenshot()

The command can be called as cy.screenshot(), cy.screenshot(fileName), cy.screenshot(options), or cy.screenshot(fileName, options). Chaining from a single element is the form relevant to this task.

Make the selector resolve to one element

An element screenshot needs an unambiguous subject. Cypress’s documented example uses .first() for a collection of posts, but choosing a unique selector is safer when the test has a known target.

Prefer a unique test hook

cy.get('[data-testid="invoice-total"]').screenshot('invoice-total')

Use a scoped query

cy.get('[data-testid="cart"]')
  .find('[data-testid="cart-total"]')
  .screenshot('cart-total')

Choose deliberately from repeated content

cy.get('.post').eq(2).screenshot('third-post')

If the query still matches multiple elements, Cypress can fail because the subject is not the single element you intended. Do not use .first() merely to silence that failure when the order is not part of the product’s contract; fix the selector or scope the query instead.

Set the visual state before capture

Screenshotting is asynchronous. Cypress documents that the page can change during the roughly 100 milliseconds before capture completes, so arrange the UI state before invoking the command. Visit the page, perform the interaction that reveals the component, and assert that the element is ready.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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
cy.visit('/notifications')
cy.get('[data-testid="open-notifications"]').click()
cy.get('[data-testid="toast"]')
  .should('be.visible')
  .and('contain', 'Saved')
  .screenshot('saved-toast')

The query and assertions establish readiness, but Cypress does not retry assertions chained after the screenshot command. Cypress also cautions that commands relying on the subject after .screenshot() are unsafe to chain, so treat the screenshot as the end of that subject’s command chain:

cy.get('[data-testid="toast"]').should('be.visible').screenshot('toast')
// Start a new query if you need another command:
cy.get('[data-testid="toast"]').should('have.attr', 'role', 'status')

Wait for content that appears later

Use an assertion, a selector-based wait, or the application’s normal synchronization rather than an arbitrary long sleep. The element should be visible, populated, and in its final layout before capture.

cy.get('[data-testid="chart"]')
  .should('be.visible')
  .find('svg')
  .should('exist')
cy.get('[data-testid="chart"]').screenshot('chart')

Add padding or crop a rectangle

Element screenshots support a padding option. A number applies the same number of pixels on every side; an array can contain up to four values using CSS shorthand notation. Cypress’s API example uses 10 pixels:

cy.get('.post').first().screenshot({ padding: 10 })
cy.get('[data-testid="toast"]').screenshot('toast-padded', {
  padding: [8, 16]
})

Padding is applied to element captures. The capture option is ignored for an element screenshot, so it cannot be used to change this behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
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.

Use clip when the desired output is a specific rectangle rather than the element’s natural bounds. Its values are pixel coordinates and dimensions:

cy.get('[data-testid="editor"]').screenshot('editor-header', {
  clip: { x: 0, y: 0, width: 800, height: 120 }
})

Choose one approach based on the output you need:

Goal Command Result
Natural element bounds .screenshot('name') The selected element’s rendered rectangle
Context around the element .screenshot({ padding: 10 }) The element plus pixel padding
Exact rectangular region .screenshot('name', { clip: { x, y, width, height } }) The specified pixel rectangle

Name and find the saved file

By default, Cypress writes screenshots to the cypress/screenshots folder, subject to your project configuration. Cypress builds paths relative to the spec; supplying a filename controls the image name within that spec-related output path. For example:

cy.get('[data-testid="profile-card"]').screenshot('profile-card')

To use a different root folder, set the screenshot folder in Cypress configuration. The exact configuration key and available settings are documented in the Capture screenshots and videos guide.

If another task needs the actual path or dimensions, configure the onAfterScreenshot callback. Cypress supplies the saved path and image dimensions to that callback, allowing you to pass the artifact to a report or archive job instead of guessing its location.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

Reusable Cypress patterns

Capture a modal after opening it

cy.get('[data-testid="open-modal"]').click()
cy.get('[role="dialog"]')
  .should('be.visible')
  .screenshot('account-modal', { padding: 12 })

Capture the first card in a list

cy.get('[data-testid="result-card"]')
  .first()
  .should('be.visible')
  .screenshot('first-result')

Capture each item separately

A single element command captures one subject. If you intentionally need one image per item, iterate and give each image a deterministic name. Keep the query inside the iteration so each command receives the current element.

cy.get('[data-testid="result-card"]').each(($card, index) => {
  cy.wrap($card).screenshot(`result-${index + 1}`)
})

Use this pattern only when multiple files are wanted; it is different from selecting one element for a single artifact.

Screenshot capture versus visual comparison

The built-in command saves an image; it does not decide whether that image matches a baseline. Cypress states, “Cypress does not perform image comparison itself,” in its Visual testing in Cypress guide. For regression testing, add a visual-testing plugin or integration that stores approved baselines, compares new captures, and provides a review workflow. Keep the capture command focused on producing a deterministic image, and let the comparison system own thresholds and approvals.

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

Troubleshoot common failures

“Element not found”

  • Verify the route loaded and the selector is present in the current DOM.
  • Use a stable data-testid or scope the query to the correct container.
  • If the element is created after an action, perform that action and assert the element exists before calling .screenshot().

More than one element matched

  • Replace a broad class selector with a unique attribute.
  • Scope with .find(), choose .eq(index), or use .first() only when first position is intentional.

The image shows an old or incomplete state

  • Assert visibility and the final text, attribute, or child node before capture.
  • Wait for the application’s loading indicator to disappear or for the network-driven content to render.
  • Remember that Cypress documents an approximately 100 ms capture interval during which the page can change.

Padding has no effect

  • Confirm that you are chaining from a DOM element. Padding applies to element screenshots, not every screenshot mode.
  • Pass a number or a CSS-shorthand array, such as padding: [8, 16].

The file is not where expected

  • Check the configured screenshots folder and the spec-relative path.
  • Use an explicit filename and the onAfterScreenshot callback when another process needs the saved path.

Commands after the screenshot behave unpredictably

Cypress cautions that further commands relying on the screenshot’s subject are unsafe to chain. Start a new cy.get() query after 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.
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.

Or skip the browser setup

If you need a screenshot service rather than a Cypress test artifact, ScreenshotNeo returns a screenshot or PDF from one GET request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

For a direct call, see the ScreenshotNeo API documentation:

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

Equivalent Python:

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

Equivalent 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}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF options, custom CSS and JavaScript, clicks before capture, waits, blocking rules, headers, cookies, user agents, authorization, timezone and 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. Its parameter names are compatible with those used by other screenshot APIs, which can simplify migration. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.

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

Practical checklist

  • Choose a selector that identifies the intended element.
  • Confirm the query yields one element, using scoping or .first() only when appropriate.
  • Put the page into its final visual state and assert readiness.
  • Use a filename for predictable artifacts.
  • Add padding for context or clip for a fixed rectangle.
  • Do not chain subject-dependent commands after the screenshot; query again.
  • Add a visual-testing integration when you need baseline comparison.

Frequently Asked Questions

Can I capture an element without giving it a filename?

Yes. Call cy.get(selector).screenshot(); Cypress generates the default suite/spec-based name in the configured screenshots folder.

Does an element screenshot capture the entire page?

No. Chaining .screenshot() from a DOM element captures that element’s rendered area. Use cy.screenshot() separately when you need a viewport or page capture.

Can Cypress compare the captured image with a baseline by itself?

No. Cypress’s built-in command saves the image; visual comparison requires a compatible plugin or integration.

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.

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