Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

How to Test Shadow DOM Elements in Cypress Studio

Studio cannot record Shadow DOM interactions. Use it for supported steps, then add Cypress’s .shadow() or includeShadowDom query to the saved spec.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cypress Studio cannot record interactions inside Shadow DOM, but Cypress tests can still test those elements. Use Studio to record the supported parts of an end-to-end flow, save the spec, and add a Cypress query with .shadow() or includeShadowDom: true. The Cypress Studio guide lists “iFrames and Shadow DOM are not supported” as limitations; that applies to Studio recording, not to Cypress’s documented Shadow DOM commands.

What Studio can and cannot do

Studio helps create and extend end-to-end tests by recording supported interactions, including clicks, typing, checks, unchecks, and selections. It saves changes to the spec file and supports inline editing. Its current guide lists iFrames and Shadow DOM as unsupported for recording. Cypress Studio documentation

So, use Studio for the parts of the page it can record, then edit the spec to add the Shadow DOM query yourself. This is a practical workflow based on Studio’s recording and editing capabilities; Cypress does not describe it as a prescribed recipe. Cypress Studio is for E2E tests; the guide also lists Component Testing, Cucumber-style tests, and recording across multiple origins as unsupported.

Choose a Cypress query for the shadow element

Use .shadow() to traverse a known component

When you know the shadow host, select it first, traverse into its open shadow root, and find the target within that root:

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.
cy.get('checkout-panel').shadow().find('button').click()

.shadow() must be chained from a DOM element that is a shadow host. It yields that host’s shadow root, so you can continue with Cypress commands such as .find() and .click(). Cypress retries while waiting for the element and shadow root, as well as chained assertions. Cypress .shadow() API

Replace checkout-panel with the actual host selector and narrow button to the intended control when a component contains more than one button.

Use includeShadowDom when the query should search across shadow boundaries

For a selector that should search through Shadow DOM, pass the option to the query:

cy.get('.shadow-button', { includeShadowDom: true }).click()

The option can be set for an individual query. Cypress also documents a configuration option to enable Shadow DOM searching more broadly. Choose the configuration route when that behavior is appropriate across queries, rather than adding the option only where needed. Cypress cy.get() API

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach What it does Useful when
.shadow() Explicitly traverses from a selected host into its shadow root. The test targets a particular component and you want the host-to-element path to be clear.
includeShadowDom: true Includes Shadow DOM in the query’s search. You want a query to search across shadow boundaries without explicitly traversing a particular host first.

Selectors must still identify the intended element. Cypress documents both APIs, but does not prescribe one method for every component.

Add the command to a Studio-created spec

  1. Open Cypress in open mode and start a test, or use Studio to extend an existing E2E test. Cypress Open Mode guide
  2. Record the supported interactions around the Shadow DOM element, such as navigating to the page and interacting with ordinary page controls.
  3. Save the test so Studio writes its changes into the spec file.
  4. Edit the spec inline or in your editor, adding the appropriate .shadow() or includeShadowDom query where the Shadow DOM interaction belongs.
  5. Run the spec and inspect the Command Log and snapshots if the query or click does not behave as expected.

Studio recording and Cypress’s command API are separate capabilities: Studio cannot record Shadow DOM interactions, while Cypress documents commands for traversing or searching Shadow DOM.

Requirements and important limits

  • The Studio guide says Studio requires internet access and sourcemaps.
  • Studio AI has additional prerequisites: Cypress 15.11.0 or later and a Cypress Cloud account with a linked project. These apply to Studio AI’s assertion recommendations, not to manually adding the Cypress commands shown above.
  • The documentation cited here does not establish whether Studio can record closed Shadow DOM roots. The examples describe Cypress query APIs and should not be taken as proof of Studio recording support or closed-root compatibility.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

The query finds no element

  • With .shadow(), confirm that the selector before it resolves to the actual shadow host. The command must be chained from a host, not from an element inside the component.
  • Check that the selector after .shadow() matches an element inside that component’s root.
  • If you are using includeShadowDom, verify that it is passed to the query that needs it, or that the relevant Cypress configuration is enabled.
  • Check whether the page has loaded the component and created its shadow root before the query runs. Cypress retries while waiting for the element, root, and chained assertions, but the selector still needs to match the page’s DOM.

A click behaves ambiguously in Chrome

Cypress documents a Chrome click issue after traversing a shadow root and lists .click('top') as a possible workaround. If the click is the failing step, try:

cy.get('checkout-panel').shadow().find('button').click('top')

Use this only when it addresses the observed click behavior; it does not change Studio’s recording limitation.

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

Or skip the browser setup:

If your goal is to capture a website image or PDF rather than test a Shadow DOM interaction, ScreenshotNeo provides a one-request screenshot API. It is not a Cypress substitute and does not test or click Shadow DOM elements. For a screenshot, the cURL call is:

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 documentation for the API details. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo to get 1,000 free screenshots a month with no card.

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.

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
PC Slower Than It Used to Be?Free scan - under a minute

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.