Skip to content

After upgrade to version 3.6.1 tests start failing with " CypressError: Timed out retrying: cy.click() failed because this element is detached from the DOM" #5743

@mschaaf

Description

@mschaaf

Current behavior:

After upgrade to 3.6.1 from 3.4.1 our cypress tests start to fail for the following constructs.

cy.get('fieldset > legend > i').should('be.visible').click()

fails with

     CypressError: Timed out retrying: cy.click() failed because this element is detached from the DOM.

<i expander="" id-to-expand="login-username-password-content" expanded="false" class="fa fa-plus-square ng-isolate-scope"></i>

Cypress requires elements be attached in the DOM to interact with them.

The previous command that ran was:

  > cy.should()

This DOM element likely became detached somewhere between the previous and current command.

Common situations why this happens:
  - Your JS framework re-rendered asynchronously
  - Your app code reacted to an event firing and removed the element

You typically need to re-query for the element or add 'guards' which delay Cypress from running new commands.

https://on.cypress.io/element-has-detached-from-dom
      at Object.cypressErr (/__cypress/runner/cypress_runner.js:104968:11)
      at Object.throwErr (/__cypress/runner/cypress_runner.js:104923:18)
      at Object.throwErrByPath (/__cypress/runner/cypress_runner.js:104955:17)
      at Object.retry (/__cypress/runner/cypress_runner.js:96290:16)
      at retryActionability (/__cypress/runner/cypress_runner.js:85007:19)
      at tryCatcher (/__cypress/runner/cypress_runner.js:139045:23)
      at Function.Promise.attempt.Promise.try (/__cypress/runner/cypress_runner.js:136320:29)
      at tryFn (/__cypress/runner/cypress_runner.js:96748:21)
      at whenStable (/__cypress/runner/cypress_runner.js:96783:12)
      at /__cypress/runner/cypress_runner.js:96333:16
      at tryCatcher (/__cypress/runner/cypress_runner.js:139045:23)
      at Promise._settlePromiseFromHandler (/__cypress/runner/cypress_runner.js:136981:31)
      at Promise._settlePromise (/__cypress/runner/cypress_runner.js:137038:18)
      at Promise._settlePromise0 (/__cypress/runner/cypress_runner.js:137083:10)
      at Promise._settlePromises (/__cypress/runner/cypress_runner.js:137162:18)
      at Promise._fulfill (/__cypress/runner/cypress_runner.js:137107:18)

We followed the link from the error message and tried to change code to:

cy.get('fieldset > legend > i').should('be.visible');
cy.get('fieldset > legend > i').click()

But this didn't change the behaviour. Also the element should be visibe from the beginning so not code is changing it in an async way.

Desired behavior:

Should not fail.

Steps to reproduce: (app code and test code)

For now we don't have them because not everytime the same tests fail. The only common thing between them is the same or similar click behavior.

These constructs were not failing with version 3.4.1.

Versions

Ubuntu 19.04
cypress 3.6.1
Electron 73

We run the tests via yarn cypress run

Any help to find the reason would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions