所以我使用了一个 while 循环,所以我的测试将在一个恒定循环中运行,直到我的后端崩溃。我已经实现了一个 try and catch(error) 所以任何前端崩溃自动化都会刷新并继续运行
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;
}}
Run Code Online (Sandbox Code Playgroud)
因此,确实任何超时错误都会自动刷新页面并继续循环。但我收到了不同的崩溃错误
(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 …Run Code Online (Sandbox Code Playgroud)