Cypress: Test if element does not exist

前端 未结 7 2143
一个人的身影
一个人的身影 2020-12-09 14:42

I want to be able to click on a check box and test that an element is no longer in the DOM in Cypress. Can someone suggest how you do it?

//This is the Test          


        
7条回答
  •  独厮守ぢ
    2020-12-09 14:57

    cy.get('[data-e2e="create-entity-field-relation-contact-name"]').should('not.exist');
    

    might lead to some false results, as some error messages get hidden. It might be better to use

    .should('not.visible');
    

    in that case.

提交回复
热议问题