Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

956
Views
Cypress: prueba si el elemento no existe

Quiero poder hacer clic en una casilla de verificación y probar que un elemento ya no está en el DOM en Cypress. ¿Alguien puede sugerir cómo lo haces?

 //This is the Test when the check box is clicked and the element is there cy.get('[type="checkbox"]').click(); cy.get('.check-box-sub-text').contains('Some text in this div.')

Quiero hacer lo contrario de la prueba anterior. Entonces, cuando hago clic nuevamente, el div con la clase no debería estar en el DOM.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Bueno, esto parece funcionar, así que me dice que tengo algo más que aprender sobre .should()

 cy.get('.check-box-sub-text').should('not.exist');
over 4 years ago · Santiago Trujillo Report

0

también puede buscar un texto que se supone que no existe:

 cy.contains('test_invite_member@gmail.com').should('not.exist')

Aquí tienes el resultado en Cypress: 0 matched elements

ingrese la descripción de la imagen aquí

documentación: https://docs.cypress.io/guides/references/assertions.html#Existence

over 4 years ago · Santiago Trujillo Report

0

Migración de Cypress 6.x+

Use .should('not.exist') para afirmar que un elemento no existe en el DOM.


No utilice la afirmación not.visible . Pasaría falsamente en <6.0, pero fallará correctamente ahora:

 // for element that was removed from the DOM // assertions below pass in < 6.0, but properly fail in 6.0+ .should('not.be.visible') .should('not.contain', 'Text')

Documentos de migración aquí: Migrating-to-Cypress-6-0

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!