【发布时间】:2021-02-25 15:50:36
【问题描述】:
我是 Test Cafe Studio 的新手,我正在尝试弄清楚如何验证网页上不存在文本。如果文本存在,我希望测试失败。任何帮助将不胜感激。
【问题讨论】:
标签: testing automation automated-tests e2e-testing testcafe
我是 Test Cafe Studio 的新手,我正在尝试弄清楚如何验证网页上不存在文本。如果文本存在,我希望测试失败。任何帮助将不胜感激。
【问题讨论】:
标签: testing automation automated-tests e2e-testing testcafe
通常,您想要断言某个元素的文本:
const elText = await Selector('#my-element').textContent;
await t
.expect(elText).notContains('some text');
如果你想检查整个页面,你可以这样做:
const elText = await Selector('html').textContent;
await t
.expect(elText).notContains('some text');
但我认为最好避免它,而是以如下方式构建测试:
【讨论】: