sumercetin
sumercetin

Reputation: 33

Is there any Playwright equivalent for waitForResource in CasperJS?

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;
}

Upvotes: 1

Views: 43

Answers (1)

Christian Baumann
Christian Baumann

Reputation: 3435

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.

Upvotes: 1

Related Questions