我有一个等待元素不出现的场景,一旦发生,我将执行单击操作。实际发生的是单击发生,尽管对带有超时选项的元素的期望未通过验证]
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 })
我尝试复制此行为的尝试未成功。 Smart Wait Mechanism for Assertions正确等待,直到断言的实际值与期望值匹配:
这是我的示例测试用例。
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)
});
请更新我的测试用例以说明问题,或提供您自己的测试用例,以便我们在实际中查看问题。