msilori
msilori

Reputation: 39

Testcafe: Is there a way to stop page loading further after the targetted element is loaded in dom?

Is there a way to force the page to stop loading any further when one of the required DOM elements has been loaded?

Similar to pressing the escape button on the browser to stop the page loading any further, is there a way to do this in Testcafe please?

Upvotes: 1

Views: 357

Answers (1)

pavelsaman
pavelsaman

Reputation: 8352

I think the following should work:

const cancelLoading = ClientFunction(() => window.stop());

then whenever you call await cancelLoading(), the page should stop loading further. For example after you find an element:

const inputField = Selector('#just-an-example');
await t
  .expect(inputField.visible).ok()
await cancelLoading();

Upvotes: 2

Related Questions