question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

doc.createTreeWalker is not a function

See original GitHub issue

Current behavior

When running a Cypress test via the Test Runner:

node ./cypress/cypress.js -- open

I’m seeing this error thrown from cypress:

cypress_runner.js:175886 TypeError: doc.createTreeWalker is not a function
    at findShadowRoots (https://localhost:8080/__cypress/runner/cypress_runner.js:166508:22)
    at collectRoots (https://localhost:8080/__cypress/runner/cypress_runner.js:166488:24)
    at Object.findAllShadowRoots (https://localhost:8080/__cypress/runner/cypress_runner.js:166498:10)
    at getElements (https://localhost:8080/__cypress/runner/cypress_runner.js:143851:45)
From previous event:
    at resolveElements (https://localhost:8080/__cypress/runner/cypress_runner.js:143905:27)
    at $Cy.get (https://localhost:8080/__cypress/runner/cypress_runner.js:143916:14)
    at $Cy.now (https://localhost:8080/__cypress/runner/cypress_runner.js:156327:47)
    at resolveElements (https://localhost:8080/__cypress/runner/cypress_runner.js:144084:19)
From previous event:
    at tryFn (https://localhost:8080/__cypress/runner/cypress_runner.js:151739:21)
    at whenStable (https://localhost:8080/__cypress/runner/cypress_runner.js:151777:12)
    at https://localhost:8080/__cypress/runner/cypress_runner.js:151269:16
From previous event:
    at $Cy.retry (https://localhost:8080/__cypress/runner/cypress_runner.js:151249:38)
    at onFailFn (https://localhost:8080/__cypress/runner/cypress_runner.js:135999:19)
From previous event:
    at $Cy.verifyUpcomingAssertions (https://localhost:8080/__cypress/runner/cypress_runner.js:136006:63)
    at https://localhost:8080/__cypress/runner/cypress_runner.js:144090:21
From previous event:
    at resolveElements (https://localhost:8080/__cypress/runner/cypress_runner.js:144084:52)
    at tryFn (https://localhost:8080/__cypress/runner/cypress_runner.js:151739:21)
    at whenStable (https://localhost:8080/__cypress/runner/cypress_runner.js:151777:12)
    at https://localhost:8080/__cypress/runner/cypress_runner.js:151269:16

Desired behavior

No error is thrown

Test code to reproduce

I can’t share the full source code due to my company’s policies. Maybe a simpler repro could be made once I have some idea of where this issue is coming from.

The line of code where this is failing is cy.findByRole('tabpanel', { hidden: false }).findByTestId('RichCommandFooter').contains('runtime');

Cypress Version

8.1.0

Other

Happy to provide more details. Our cypress.js file has a good amount going on it, but I’m not sure what would be most relevant to help debug.

@testing-library/cypress is on version 8.0.1

Screen Shot 2022-03-28 at 6 40 44 PM

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
BlueWindscommented, Nov 28, 2022

This looks suspiciously like another manifestation of the same underlaying bug as https://github.com/cypress-io/cypress/issues/7306. We’ve spent a lot of work looking into that for Cypress 12.0.0 - my hope is that this issue will be resolved in Cy12, which should come out next week.

Going to assign myself so I remember to follow up here after release.

1reaction
aquanow-rtrancommented, Oct 31, 2022

Hi everyone, would just like to leave my two cents on this issue as I am also experiencing it. I have noticed in my tests that the createTreeWalker is not a function error occurs when the tests are trying to get an element that is currently being loaded in. Have seen two different instances where it has happened. Once when I’m performing a cy.get().contains() and another where my table hasn’t fully loaded in yet. My workaround was to change cy.get().contains() to cy.contains(selector, content) and to input a {timeout: 10000} Hope my solution is able to at least get your tests running until a proper fix could be applied

Read more comments on GitHub >

github_iconTop Results From Across the Web

doc.createTreeWalker is not a function - Stack Overflow
1 Answer 1 ; // using jquery to avoid the treeWalker (used by the .find() command) cy.get('im-page.hydrated im-button:eq(1) button.success.
Read more >
cypress-io/cypress - Gitter
cy.get('div.myclass > section:first-child').find('span:contains("myText")'); Im getting error: TypeError doc.createTreeWalker is not a function
Read more >
Document.createTreeWalker() - Web APIs | MDN
Since attributes are never children of other nodes, they do not appear when traversing over the document tree. NodeFilter.
Read more >
Introduction to the TreeWalker object of DOM - JavaScript Kit
document.createTreeWalker() method. The TreeWalker object can come off as mysterious and complicated to some, but it really is just realized through a single ......
Read more >
Cypress.dom
Cypress.dom.method() is a collection of DOM related helper methods. There are actually dozens of methods attached to Cypress.dom that are not documented.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found