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.
Asked
Active
Viewed 2,385 times
2 Answers
14
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}, () => {
...
})

Nopal Sad
- 516
- 1
- 7
6
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')

Alapan Das
- 17,144
- 3
- 29
- 52