Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element is not visible because it has CSS property: 'position: fixed' and its being covered by another element

Tags:

cypress

Can someone help me with this Cypress error?

Cypress Error: Timed out retrying: expected '<div.sub-categories-list>' to be '0 visible'

This element '<div.sub-categories-list>' is not visible because it has CSS property: 'position: fixed' and its being covered by another element:

undefined
like image 914
ARPITA srivastava Avatar asked Dec 31 '22 16:12

ARPITA srivastava


1 Answers

The element you are asserting is not visible within the viewport and probably have to be scrolled to in order to be visible.

Cypress do not automatically scroll to elements during the test run, but you can use scrollIntoView(), so write your assertion like this:

cy.get('#yourElement')
    .scrollIntoView()
    .should('be.visible')
like image 199
Diogo Rocha Avatar answered Jan 13 '23 13:01

Diogo Rocha