Playwright Wait for Page to completely load and XHR / Ajax Calls complete

Viewed 1351

I have previously used Puppeteer in Node.js and I am now using Microsoft.Playwright in .Net

I have a need to wait until all XHR / Ajax requests have finished so that the page is in a truly "ready" state. Using timouts and delays is unreliable.

With Puppeteer I used a library Pending XHR Puppeteer https://www.npmjs.com/package/pending-xhr-puppeteer which was designed for this issue specifically

So in node.js I would load the page etc inside a warapper and then when needed I would just call

await pageWrapper.waitForAllXhrFinished()

I am assuming that behind the scenes it is keeping count of the ajax requests sent and returning the function once they have all returned.

Note: for one of my scenarios there are 2 XHR requests set and they are from exactly the same URL.

How can we achieve this in Playwright for .Net ?

0 Answers
Related