title: Protractor check console for errors after action
body: <p>In my test I need to check if there are errors in the console after clicking a button. But the only errors I get are from the login page, then when the page loads after that. But nothing after the button click, and I know there are errors happening. And if there's not errors, there are logs. My function doesn't seem to capture those either. It's pretty frustrating. Here's my code. (I have the login code in my <code>config.js</code> file.)</p>
  
  <pre><code>function checkConsoleErrors() {
    browser.manage().logs().get('browser').then(function (browserLog) {
      if (browserLog.length) {
        browserLog.forEach(function(log){
          var error = log.level.value &gt; 900;
          if(error) {
            console.error('ERROR: ', log.message);
            if (log.timestamp &gt; timestamp) { 
              expect(error).toBeFalsy(); //only check for errors after the button click
            }
          }
        });
      }
    });
  }
  
  describe('Errors', function() {
    afterEach(function() {
      checkConsoleErrors();
    });
    it('should have no errors', function() {
      //code here
      btn.click();
      timestamp = moment().valueOf(); //capture the time the button was clicked
      browser.sleep(10000); //wait
    });
  });
  </code></pre>
  
  <p>Am I missing something? Is there a different/better way to do this?</p>