Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Why display none for cypress is still visible?

I am testing my website using cypress, but there's one thing that confused me, is that when I using :

display:none 

And I use this line to test if the div still exist in the page:

cy.get('[data-cy=searchBar]').should('not.exist')

It will still be detected as visible when testing, I think the reason is that I can still see the element inside the chrome dev tool, but I can't see it on the web page.

I know that I can simply use CSS attribute to check the display to finish my test, but I am wondering how this visible in cypress is designed, and why in this case it doesn't work?

enter image description here

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

exist and visible are two different assertions. Exist checks whether the element is present in the DOM. Visible checks whether the element is visible on the DOM.

Now for your element where it has a property of display: none, this signifies that element is not visible but it does exists.

cy.get('[data-cy=searchBar]').should('be.visible') //Fails
cy.get('[data-cy=searchBar]').should('exist') //Passes
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda