title: How to get browser console error messages using Selenium WebDriver + python
body: <p><a href="https://i.stack.imgur.com/wan1s.png" rel="nofollow noreferrer">Console error png </a>We have been trying to print the console errors for the particular site by using the following code. But we are unable to catch console errors. Can anyone give quick response
  But we are getting </p>
  
  <p>Line of Code :</p>
  
  <pre><code>driver.get_log('browser')
  </code></pre>
  
  <p>Error :</p>
  
  <pre><code>[{u'source': u'deprecation', u'message': u"https://xxxxx/static/vendor/vendor.bundle.js?v=16 902 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", u'timestamp': 1515593047810, u'level': u'WARNING'}]
  </code></pre>
  
  <p>Line of Code :</p>
  
  <pre><code>driver.get_log('driver')
  </code></pre>
  
  <p>Error : </p>
  
  <pre><code>[{u'timestamp': 1515593061561, u'message': u'Unable to evaluate script: disconnected: not connected to DevTools\n', u'level': u'WARNING'}, {u'timestamp': 1515593071847, u'message': u'Unable to evaluate script: disconnected: not connected to DevTools\n', u'level': u'WARNING'}]
  </code></pre>
  
  <p>Code Block :</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  
  capabilities = DesiredCapabilities.CHROME
  capabilities['loggingPrefs'] = { 'browser':'ALL' }
  driver = webdriver.Chrome(desired_capabilities=capabilities)
  driver.get('url')
  elem = driver.find_element_by_id('username')
  elem.send_keys('xxxx')
  elem1 = driver.find_element_by_name('password')
  elem1.send_keys('xxxx')
  elem2 = driver.find_element_by_class_name('btn-info')
  elem2.click()
  driver.get('url')
  for entry in driver.get_log('browser'):
      print entry
  </code></pre>