So I used a while loop so my test will run in a constant loop until my back-end will crash. I've implemented a try and catch(error) so any front-end crash the automation will refresh and keep running
while(true){
try{
await page.waitFor(selector)
await page.click(selector)
}
catch(error){
console.log("FE crashed with\n\n" + error + "\n\nRefreshing page and continuing profile switching")
await page.reload(page);
continue;
}}
So indeed any timeout error the automation refreshes the page and continuing the loop. but Im recieving a different crash error
(node:6535) UnhandledPromiseRejectionWarning: Error: Page crashed!
at Page._onTargetCrashed (/home/raymond/node_modules/puppeteer/lib/Page.js:170:24)
at CDPSession.Page.client.on.event (/home/raymond/node_modules/puppeteer/lib/Page.js:125:56)
at CDPSession.emit (events.js:182:13)
at CDPSession._onMessage (/home/raymond/node_modules/puppeteer/lib/Connection.js:200:12)
at Connection._onMessage (/home/raymond/node_modules/puppeteer/lib/Connection.js:112:17)
at _tickCallback (internal/process/next_tick.js:43:7)
at listOnTimeout (timers.js:294:7)
at processTimers (timers.js:268:5)
(node:6535) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
How can I handle this error?, if I refresh the page manually everything works fine. Thanks