Verification

API reference

  1. page.on('console', msg => console.log(msg.text()))
  2. page.on('console', msg => {
  3. if (msg.type() === 'error')
  4. console.log(`Error text: "${msg.text()}"`);
  5. });
  6. const [msg] = await Promise.all([
  7. page.waitForEvent('console'),
  8. // Issue console.log inside the page
  9. page.evaluate(() => {
  10. console.log('hello', 42, {foo: 'bar'});
  11. }),
  12. ]);
  13. await msg.args[0].jsonValue() // hello

API reference

Listen for uncaught exceptions in the page with the pagerror event.

API reference

“requestfailed”

  1. page.on('requestfailed', request => {
  2. console.log(request.url() + ' ' + request.failure().errorText);
  3. });

“dialog” - handle alert, confirm, prompt

“popup” - handle popup windows

  1. const [popup] = await Promise.all([
  2. page.waitForEvent('popup'),
  3. ]);

API reference