如何使用puppeteer的page.evaluate()获取所有网络请求?

问题描述 投票:0回答:1

是否有任何方法可以使page.evaluate()等待到至少500毫秒没有网络请求(例如page.goto()等待networkidle0)?

例如:

await page.evaluate('window.location = "https://example.com"');
// listen to the network requests until there are no requests fired for at least 500 ms
javascript puppeteer
1个回答
0
投票

waitUntil仅在导航上下文中才有意义。如果您想为waitUntil本身提供evaluate()选项,那么答案是否定的。但是,如果使用evaluate()触发导航,则可以使用waitForNavigation()

await page.evaluate(() => window.location = "https://example.com")
await page.waitForNavigation({waitUntil: 'networkidle0'});
© www.soinside.com 2019 - 2024. All rights reserved.