如何在柏树中做`cy.notContains(Text)`? [英] How to do `cy.notContains(text)` in cypress?

查看:40
本文介绍了如何在柏树中做`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')

这篇关于如何在柏树中做`cy.notContains(Text)`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆