When 'is.visible' failure, error shows 'is being covered by another element: undefined'
See original GitHub issueCurrent behavior:
I am expecting a test to pass on an element that is visible. cy.get(#el).should('be.visible')
.
When I look at the test in the GUI, I can see that it is visible and has been scrolled to after get
ing the element. But the ‘This element is not visible’ icon is showing against the test.
The element I am testing against is a child of a div that has position: fixed
. If I remove the position
from it, the test passes as expected.
Desired behavior:
The test should pass as the item is visible
How to reproduce:
I have reproduced this bug here: https://github.com/anthwinter/cypress-test-tiny
It uses express, so once you have cloned the repo, run node index.js
and head to localhost:3000
before running the test.
- Operating System: macOs 10.13.3
- Cypress Version: 2.0.4
- Browser Version: Chrome 64
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Element is not visible because it has CSS property: 'position
The element you are asserting is not visible within the viewport and probably have to be scrolled to in order to be visible....
Read more >element is being covered by another element cypress - You.com
The element you are asserting is not visible within the viewport and probably have to be scrolled to in order to be visible....
Read more >Debug the Element Visibility Problems in Cypress
Cypress fails the test when the clearly visible "Cypress is amazing! ... In the video below I show how to debug the visibility...
Read more >Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >cypress-io/cypress - Gitter
@bahmutov here is a repro for "covered by another element: undefined" context('Finding Elements', function () { describe('Inability to find visible ...
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
Response to @anthw, original post https://github.com/cypress-io/cypress/issues/1379#issue-300286449
The button element you are asserting on is technically not visible within the viewport. The button would have to be scrolled to in order to be visible.
We do not automatically scroll to elements during the test run. We do however scroll to the element when reviewing the tests that have previously run in order to help with debugging.
cy.get()
and.find()
NEVER scroll anything during the test run. You can see what is actually scrolling during the test run by placing.pause()
in your tests and seeing each command execute. Some of this is noted in our docs here: https://docs.cypress.io/guides/core-concepts/interacting-with-elements.html#ScrollingThis is not a bug. This is expected behavior and the only way we can support testing scrolling behavior + visibility.
To test that the button is visible, you would need to write:
As for the error message indicating
is being covered by another element: undefined
- this is a bug, it shouldn’t logundefined
here.Response to @Knaledge https://github.com/cypress-io/cypress/issues/1379#issuecomment-422154084
Unfortunately, the url in your provided test no longer works - although I confirmed this behavior previously and can reproduce another way. The bug looks to be similar to the original posters - where
undefined
should not be logged as the element covering another element.NEED A REPRODUCIBLE EXAMPLE
@Jazzepi @krike @mrmojica @kmichetti @andezzat
This is not enough information for us to run this test code on our own to verify there is a visibility issue with
fixed
elements. We would need a reproducible example of this in order to address this. Can you open a new issue and provide one?Actual Bug
We will be repurposing this issue to track the bug where the error message prints:
If you have any other confirmed bug concerning visibility - check the existing issues or open a new issue.
Released in
3.7.0
.