Skip to content

Querying shadow dom in cy.within causes error 'root.getRootNode is not a function' #8478

Closed
@chrisbreiding

Description

@chrisbreiding
Contributor

Current behavior:

Querying shadow dom in a cy.within callback function causes the following error:

root.getRootNode is not a function

Screen Shot 2020-09-02 at 11 09 03 AM

Desired behavior:

Querying the shadow dom should work inside the cy.within callback function.

Test code to reproduce

cypress.json

{
  "experimentalShadowDomSupport": true
}

cypress/fixures/shadow-dom.html

<html>
<body>
  <div id="outer">
    <div id="host"></div>
  </div>

  <script>
    document
    .getElementById('host')
    .attachShadow({ mode: 'open' })
    .innerHTML = '<div class="in-shadow-dom">In Shadow DOM</div>'
  </script>
</body>
</html>

spec.js

it('fails querying shadow dom in cy.within', () => {
  cy.visit('/cypress/fixures/shadow-dom.html')
  cy.get('#outer').within(() => {
    cy.get('.in-shadow-dom', { includeShadowDom: true })
  })
})

Versions

Cypress 4.8.0+

Activity

self-assigned this
on Sep 2, 2020
cypress-bot

cypress-bot commented on Sep 4, 2020

@cypress-bot
Contributor

The code for this is done in cypress-io/cypress#8505, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

cypress-bot

cypress-bot commented on Sep 15, 2020

@cypress-bot
Contributor

Released in 5.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.2.0, please open a new issue.

locked as resolved and limited conversation to collaborators on Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @chrisbreiding

    Issue actions

      Querying shadow dom in cy.within causes error 'root.getRootNode is not a function' · Issue #8478 · cypress-io/cypress