Test fails as a result of a visible element being deemed not visible.
See original GitHub issueCurrent behavior
Cypress fails a test indicating that an element is not visible, but the element is actually visible onscreen.
Desired behavior
The test passes because the element is visible.
Test code to reproduce
context('Visibility Issue', function () {
it('Test', function () {
cy.visit('https://play.vidyard.com/EmrX1jweW4rRGPRJEQeqtn?first_frame=1');
cy.wait(5000); // Just to make sure everything is loaded.
cy.contains('Cypress is amazing!')
.should('be.visible');
});
});
The element is clearly visible onscreen, yet this test fails because it says that the element is covered by another element. 🤷♂️
Versions
This occurs in Cypress 5.1.0 and 6.0.0 in Chrome 87, Firefox 82, Edge, 87, and Electron 87 on macOS 10.15.7.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Debug the Element Visibility Problems in Cypress
Cypress fails the test when the clearly visible "Cypress is amazing! ... The test is failing because an element is deemed to be...
Read more >angularjs - Testing whether certain elements are visible or not
Thus, as an example, the right way to test if the element is hidden would be: expect(element.find('.value-entry input').hasClass('ng-hide')).toBe(true);.
Read more >Unable to verify Element Visibility for IF statement. in Test Studio
Hi All, I am Unable to verify Element Visibility for IF statement. The scenario is I am using test step(Quick Step) as "Verify...
Read more >Cypress basics: check if element exists - Filip Hric
Our test would not fail on line 13, but on line 14. Our .should('be.visible') assertion would be visible, since our element is not...
Read more >Debug Cypress element visibility issues - YouTube
This video shows how to step through the Cypress.dom.isVisible function to investigate why Cypress thinks an element is invisible, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @bartbriek .
I don’t think this is related.
Cypress 6.0.0 introduced a change to how elements that do not exist respond to the
.should('not.be.visible')
assertion. See the changelog for full details, but theelement_that_is_not_visible
does not exist in the page (as evidenced by the0
next to it in the screenshot you provided) and therefore the.should('not.be.visible')
assertion will fail in Cypress 6.1.0. The assertion would not have failed in version 5.6.0 which would explain why it was passing for you previously. After upgrading to Cypress 6.0.0 or above, the assertion that should be used on this element is.should('not.exist')
.Hope this helps!
I have described how I debug visibility problems and step through Cypress code in
Cypress.dom.isVisible
using your code as an example. Read https://glebbahmutov.com/blog/debug-visibility/ and/or watch https://www.youtube.com/watch?v=nSmHxxwceDU