How to reload page in Puppeteer?
You always can reload page via DOM, like this:
await page.evaluate(() => {
location.reload(true)
})
or here is a lot of ways how you can reload page with browser JS via DOM
Also, you can navigate your puppeteer back and forward. Like this:
await page.goBack();
await page.goForward();
I manage to solve it using a while loop.
for (let appUrl of appUrls) {
var count = i++;
while(true){
try{
await page.goto(appUrl);
const appName = await page.$eval('div.det-name-int', div => div.innerText.trim());
console.log('\n' + count);
console.log('Name: ' , appName);
break;
} catch(e){
console.log('\n' + count);
console.log('ERROR');
await page.reload(appUrl);
continue;
}
}
This works for me:
await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] });
See Puppeteer docs for details: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagereloadoptions