Watir:如何验证网页中不存在文本
我正在编写一个删除记录的测试,并且我需要验证该记录在删除后是否不再存在。我知道如何使用“browser.text.include?”验证页面中存在记录文本,但是有没有办法可以验证该文本不存在 代替现在?如果文本在据称被删除后仍然存在,我需要测试失败。 我已经搜索过,但搜索到的唯一结果告诉我如何验证文本是否存在 - 这与我需要的相反。
非常感谢。
I'm writing a test where I delete a record, and I need to verify that the record is no longer present after I've deleted it. I know how to verify the record text is present in a page, with "browser.text.include?", but is there a way that I can verify that the text is not present instead? I need the test to fail if the text is still present after it's supposedly been deleted.
I've searched but the only hits I get on search tell me how to verify text is present - which is the opposite of what I need.
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
浏览器.文本.包括?返回一个布尔值(实际上是 truetype 或 falsetype,但现在不是讨论的时候),因此否定它会反转您的搜索。
请随意根据您自己的需求进行定制。附言。这基本上是 ry 的答案,只是针对食脸獾。
根据查克的建议,出于历史兴趣而添加:
添加以显示“其他”示例:
browser.text.include? returns a boolean value (actually a truetype or a falsetype, but this isn't the time for that discussion), so negating it will inverse your search.
Feel free to customise for your own needs. PS. This is basically ry's answer, only with face-eating badgers.
Added for historical interest, from Chuck's suggestion:
Added to show an "else" example:
怎么样:
How about:
或者取决于您使用的测试框架
or depending on what testing framework you are using
如果记录是包裹HTML元素,使用exists?方法是验证存在性的另一种方法。
已删除记录(示例)
检查脚本
If the record is wrapped HTML element, using exist? method is the another way to verify existence.
deleted record (sample)
check script