DEV Community

Discussion on: Front End Development automation with Puppeteer. Part 1

Collapse
 
tosirisuk profile image
Richard

Is it normal to use await with then() and catch() in Puppeteer?

await page.waitForSelector('.notification-message')
.then( async () => {
signale.success('Form was submitted successfully'); // This is a fancy console.log()
await page.screenshot({path: automated_test_success_$dateString.png});
browser.close();
})
.catch(() => signale.fatal(new Error('Submit form failed')));

Collapse
 
papaponmx profile image
Jaime Rios

It is a matter of style preference, the idea is to catch important errors.