0

I try this :

// global scope
caseOfTimeout = (step, sel) => {
    console.log('ERROR on step "' + step + '", can\'t find selector [' + sel + ']');
    process.exit(1);
}

// (...) truncated
// IIFE await/async part :
sel = 'foobar';
step = "Click on foobar";
if (debug) console.log(step);
await page.waitForSelector(sel, { timeout: 5000 })
.catch(caseOfTimeout(step, sel));
//.catch(function(err) { console.log("ERR " + step + " selector " + sel); process.exit(1); })
await page.click(sel);

If I uncomment the commented .catch() version, it works, but not as-is.

Does I miss something ? I have many steps like this, maybe there's a better way to handle timeouts without having to repeat myself on each step ?

0 Answers0