Is there any Playwright equivalent for waitForResource in CasperJS?

43 Views Asked by At

Is there any Playwright equivalent for waitForResource in CasperJS? How can I write the below code using Playwright?

casper.waitForResource(function test(resource) {
    return resource.url.indexOf("submit") > -1;
}
1

There are 1 best solutions below

0
Christian Baumann On BEST ANSWER

You can use page.waitForRequest():

await page.waitForRequest(request => request.url().indexOf('submit') > -1);

This will pause the execution until a request is made that contains the string "submit" in its URL.