I had a problem with a long-time loading webpage that is partially solved here. If I try to reload the page with
await page.evaluate(() => {
location.reload(true);
});
It is stuck again. It seems like nothing that I'd do with page.evaluate goes through to the browser while it is in this loading state. Manually refreshing in headless mode=false with location.reload(true) while the code is stuck works. How can I refresh the website or somehow make page.evaluate usable again?
Edit: The website loads for a long time after a click on a next page button. It does not always happen, but only a very few times.
CodePudding user response:
This is not recommended, if it is to reload after a timeout, you can
try {
await page.goto(url, {timeout: 10000});
} catch (e) {
console.log("time out , reload!");
await page.reload(url);
await page.evaluate(() => {
......
});
}
CodePudding user response:
just to make sure test this.
await page.evaluate(() => {
window.location.reload(true);
});
or
await page.evaluate(() => {
document.location.reload(true);
});