question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When 'is.visible' failure, error shows 'is being covered by another element: undefined'

See original GitHub issue

Current 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 geting 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:closed
  • Created 6 years ago
  • Reactions:7
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jennifer-shehanecommented, Jun 11, 2019

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#Scrolling

This 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:

describe('Button', () => {
  it('should be visible', () => {
    cy.viewport(640, 480)
    cy.visit('index.html')
    cy.get('#buttonElement')
      .scrollIntoView()
      .should('be.visible')
  })
})

As for the error message indicating is being covered by another element: undefined - this is a bug, it shouldn’t log undefined 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:

is being covered by another element: undefined

If you have any other confirmed bug concerning visibility - check the existing issues or open a new issue.

0reactions
cypress-bot[bot]commented, Nov 27, 2019

Released in 3.7.0.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found