如何在柏树中做`cy.notContains(Text)`?

我可以用cy.contains('hello')检查柏树中是否存在文本,但现在我从页面中删除hello,我想检查hello不存在,我该如何做cy.notContains('hello')这样的事情?


解决方案

对于不存在检查‘hello’的简单问题,您可以在.should()后面使用.contain('hello')。因此,整个页面如下所示:

// code to delete hello

cy.contains('hello').should('not.exist')

或者您可以进一步将其缩小到应用程序的特定区域:

// code to delete hello

cy.get('.element-had-hello').should('not.include.text', 'hello')

相关文章