Cypress shadow-root inside of shadow-root

3.3k Views Asked by At

How do I find the element that is inside of shadow-root which is inside of other shadow-root? I'm new to this and tried .shadow() function.

2

There are 2 best solutions below

0
On BEST ANSWER

If you're using Cypress v10, then the configuration is in the file cypress.config.js and the format for setting global shadow enabling is

const { defineConfig } = require("cypress");

module.exports = defineConfig({
  e2e: {
    ...
  },
  ...
  includeShadowDom: true
})

Or use test-specific configuration

it('tests some shadow dom elements', {includeShadowDom: true}, () => {
  ...
})
0
On

You don't have to use .shadow() every time. Go to cypress.json file and add the following includeShadowDom: true.

Now with this added all your get, find commands will automatically traverse through the shadow dom and reach the element.

cy.get('some-element').should('be.visible')