title: How to get all console messages with puppeteer? including errors, CSP violations, failed resources, etc
body: <p>I am fetching a page with puppeteer that has some errors in the browser console but the puppeteer's console event is not being triggered by all of the console messages.</p>
  
  <p>The puppeteer chromium browser shows multiple console messages</p>
  
  <p><img src="https://i.stack.imgur.com/j083t.png" alt="multiple console messages"></p>
  
  <p>However, puppeteer only console logs one thing in node</p>
  
  <p><img src="https://i.stack.imgur.com/OgWer.png" alt="console logs one thing in node"></p>
  
  <p>Here is the script I am currently using:</p>
  
  <pre><code>const puppeteer = require('puppeteer');
  
  (async () =&gt; {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();
    page.on('console', msg =&gt; console.log('PAGE LOG:', msg.text));
    await page.goto('https://pagewithsomeconsoleerrors.com');
    await browser.close();
  })();
  </code></pre>
  
  <p>Edit: As stated in my comment below, I did try the page.waitFor(5000) command that Everettss recommended but that didn't work.</p>
  
  <p>Edit2: removed spread operator from <code>msg.text</code> as it was there by accident.</p>
  
  <p>Edit3: I opened an issue on github regarding this with similar but different example screenshots: <a href="https://github.com/GoogleChrome/puppeteer/issues/1512" rel="noreferrer">https://github.com/GoogleChrome/puppeteer/issues/1512</a></p>