I am writing some e2e tests with TestCafe, I am using the t.wait
mechanism to wait for elements to appear on the page and in the dom, like this :
await t.wait(10000);
let sel=Selector("div").withAttribute('data-testid', 'something');
// continue with the test
This approach fails sometimes, and the test fails.
Is there a way to wait for that exact element to appear on the page ? Once the element appears, continue executing the test. I thought of doing something like this :
let sel=Selector("div").withAttribute('data-testid', 'something');
while (!sel.exists && !sel.visible) {
continue
}
// continue with the test
But there are obvious issues with this method, and it's not very elegant. So, does anyone else know a better solution for this ?