3 回答
TA贡献1859条经验 获得超6个赞
您应该能够执行以下操作:
await page.waitForFunction((finalUrl) => {
return document.location === finalUrl
}, {}, finalUrl).catch(retry)
但它可能更简单:
await page.waitForResponse(finalUrl).catch(retry)
TA贡献1951条经验 获得超3个赞
也许是这样的:
if (page.url() !== finalURL) { // await is not needed here
let t = 0;
busy: while(t < 400) { // was '> 400' a typo?
const [_, navigation] = await Promise.allSettled([
page.click('#tryAgainLink'),
page.waitForNavigation(),
]);
if (navigation.status === 'fulfilled') break busy;
t++;
await page.waitForTimeout(1500);
}
}
TA贡献1865条经验 获得超7个赞
我使用这种方法:
async function isNavigation() {
try {
await page.evaluate(() => console.log('any code'))
return false
} catch (ex) {
// check error, should be:
// "Execution context was destroyed, most likely because of a navigation"
return true
}
}
添加回答
举报