我有一个场景,我等待元素不出现,一旦发生,我执行点击动作,实际发生的情况是,点击发生,虽然期待一个元素的超时选项是无效的。
await t.expect(StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })
await t.click(someTab)
我希望第二行能在第一行断言为正后才执行
尝试
await t.expect(await StatusOnProgressIcon.exists).notOk('Unexistence of On progress status icon', { timeout: 120000 })
我试图复制这种行为,但没有成功。该 断言的智能等待机制 正确地等待,直到断言的实际值与预期值相匹配。
这是我的测试用例
61609192.html
<!DOCTYPE html>
<head>
</head>
<body>
<p id="icon">Status Icon</p>
<button id="button" type="button">Add to cart</button>
</body>
<script>
setTimeout(() => {
document.getElementById("icon").remove();
}, 8000);
</script>
</html>
61609192.js
import { Selector} from 'testcafe';
fixture('fixture')
.page('./61609192.html');
test('test', async t => {
const icon = Selector("#icon");
const button = Selector("button");
await t.expect(icon.exists).notOk('Icon does not exist', { timeout: 120000 })
await t.click(button)
});
请更新我的测试用例来说明这个问题,或者提供你自己的测试用例,让我们可以看到这个问题的实际情况。