TestCafe-如何检查断言中的值是否大于或等于

问题描述 投票:0回答:1

如果大于或等于1,我想检查显示在选择器下方的值

<span class="badge badge-pill badge-white"> 0 </span>

((将值“ 0”逐步更改为“ 1”或“ 2”。)

我在common.js中定义了此选择器

this.pill = Selector('[class*=badge-white]');

并写了以下断言:

await t.expect((common.pill).innerText).gte(1);

我收到以下错误:“ AssertionError:预期'1'是数字或日期'。我不知道如何将((common.pill).innerText)转换为数字?我试图这样:] >

await t.expect(Number((common.pill).innerText)).gte(1);

但是它不起作用。当我检查值是否深等于例如“ 3”时,我写:

await t.expect((common.pill).innerText).eql('3');

并且有效。有人可以帮助我如何检查大于或等于的值?我进行了仔细的研究,但找不到解决方法https://devexpress.github.io/testcafe/documentation/guides/basic-guides/assert.html:(

我在创建const时找到了解决方案

const number = await common.pill.innerText;

await t.expect(Number(number)).gte(1);

它有效!!!!!!!!!!!!!!!!!!!!!

所以我的问题是为什么下面的代码不起作用

await t.expect(Number((common.pill).innerText)).gte(1);

我想检查显示在选择器下方的值是否大于或等于1 0

javascript testing automated-tests e2e-testing testcafe
1个回答
0
投票
您的代码
© www.soinside.com 2019 - 2024. All rights reserved.