Skip to content

Conflicting information on using .should('be.visible') before .click() #14889

Discussion options

You must be logged in to vote

The repo is at https://github.com/bahmutov/next-js-example-may-2020

The test as written without an explicit visibility check shows the eye icon at the moment of the cy.get command, I believe. Thus if this is the first command, it is racing against the Next framework. Sometimes cy.get finds the element visible, and sometimes not yet. Thus if you reload the tests you will see different results, as this video below demonstrates

We want to remove non-deterministic behavior, and adding cy.get('...').should('be.visible') ensures the Next app is fully rendered before proceeding to cy.click command. I really do not like the "invisible element" badge in the Command Log. Thus adding an assertion l…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by bahmutov
Comment options

You must be logged in to vote
1 reply
@IlCallo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants