Puppeteer: How to handle Popup
2020-08-17
I came up with this little script url=’https://www.mywebsite.com’; await page.goto(url, { waitUntil: ‘networkidle0’ }); await page.type(‘#logonIdentifier’, ‘[email protected]’); await page.type(‘#password’, ‘mypassword’); await page.screenshot({ path: ‘/puppeteer/step01.png’}); //this is where i handle popup windows page.on(‘dialog’, async dialog => { console.log(dialog.message()); await dialog.dismiss(); // or await dialog.accept() }); await page.click(‘#next’); await page.waitForNavigation(); console.log(await page.content()); await page.screenshot({ path: ‘/puppeteer/step03.png’});Read More →