Skip to content

Is selector retried only till the last successfull assertion? #6338

@ystoev

Description

@ystoev

Description

Hello, we have a flaky test in our project and by trial and error we discovered that it might be caused by an assertion in the middle of a query chain. We have something like this (i modified the real example for simplicity):

cy.find('div').eq(2).should('contain', 'Header').children('.child').eq(3).should('contain', 'child');
  1. If we start the query and our div contains the text "Header" we will continue the execution.
  2. Since our application is loading at this stage, the text child is not visible.
  3. Once the data loads, the entire div is re-rendered, but cypress only will retry the selector from .children('.child').eq(3) because the assertion .should('contain', 'Header') was met in point 1
  4. Since the div that cypress has in the query is detached, it will fail with an error like:
Timed out retrying after 30000ms: cy.children() failed because the page updated as a result of this command, but you tried to continue the command chain. The subject is no longer attached to the DOM, and Cypress cannot requery the page after commands such as cy.children().

Is my understanding correct? If so i think that in the page dedicated to Retry-ability it will be useful to have this explicitly mentioned.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions