mercredi 23 décembre 2020

Testcafe .parent() of Selector sporadically fails before timeout

I have a TestCafe test that checks if a Selector's parent exists and somehow it fails every other time. Here's the relevant code:

logWithTimestamp("Starts...");  // Prints "[2020-12-23T12:02:04.476Z] Starts..."
let state = await Selector('#indberetningsflow-knap-trin-stamdata', {timeout: 30000}).parent().exists;
logWithTimestamp(`State: ${state}`);  // Prints "[2020-12-23T12:02:04.618Z] State: false"
await t.expect(state).ok()  // Sometimes fails

As you can see, it fails after less than 200ms, even though the timeout is set explicitly to 30000. Now, I have an idea that maybe it fails when the selector is found, but the parent is not yet loaded. If this is true, why does TestCafe not wait for the parent to appear, and what can I do about it?

Aucun commentaire:

Enregistrer un commentaire