我想检查我创建的页面上是否存在“64”。
const x = Selector('.FilterCockpit--header--count').withText('64');
以下测试失败。
test('x', async t => {
await t
.expect((x).exists).ok()
});
HTML代码:
<div class="FilterCockpit--header--results">
<span class="FilterCockpit--header--count">
64
</span>
Results
</div>
我做错了什么?预先感谢您的帮助。
最佳答案
我已经用最新的 1.1.4 版本的 TestCafe 执行了你的测试用例并通过了:
这是我的完整测试用例和基于您的代码片段的测试文件:
import { Selector} from 'testcafe';
fixture('fixture')
.page('file:///Temp/56074194.html');
const x = Selector('.FilterCockpit--header--count').withText('64');
test('x', async t => {
await t
.expect((x).exists).ok()
});
56074194.html
<div class="FilterCockpit--header--results">
<span class="FilterCockpit--header--count">
64
</span>
Results
</div>
也许,有些情况可能会破坏测试执行。如果我需要执行任何其他步骤,请告诉我。
关于testing - 如何检查Testcafe中是否存在文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56074194/