赛普拉斯:测试元素是否不存在 [英] Cypress: Test if element does not exist
本文介绍了赛普拉斯:测试元素是否不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够单击一个复选框并测试Cypress中DOM中是否不再有某个元素。有人可以建议您如何做吗?
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 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.')
我想做与上面测试相反的事情。因此,当我再次单击它时,具有该类的div不应位于DOM中。
I want to do the opposite of the test above. So when I click it again the div with the class should not be in the DOM.
推荐答案
这似乎可行,所以它告诉我还有更多有关.should()
Well this seems to work, so it tells me I have some more to learn about .should()
cy.get('.check-box-sub-text').should('not.exist');
这篇关于赛普拉斯:测试元素是否不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文