title: Python: Selenium: Unable to get browser console logs
body: <p>Good morning,</p>
  
  <p>I was trying to access a web application and collect browser console logs (Web Developer -> Web Console). </p>
  
  <p>I am getting an error</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>File "test1.py", line 28, in &lt;module&gt;
      logs = driver.get_log('browser')
    File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1262, in get_log
      return self.execute(Command.GET_LOG, {'type': log_type})['value']
    File "C:\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
      self.error_handler.check_response(response)
    File "C:\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 208, in check_response
      raise exception_class(value)
  selenium.common.exceptions.WebDriverException: Message: HTTP method not allowed</code></pre>
  </div>
  </div>
  </p>
  
  <p>my code is like this.</p>
  
  <pre class="lang-python prettyprint-override"><code>from selenium import webdriver
  from selenium.webdriver.firefox.options import Options
  from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.action_chains import ActionChains
  import time
  from selenium.webdriver.support.ui import WebDriverWait
  
  binary = r'C:\Program Files\Mozilla Firefox\firefox.exe'
  options = Options()
  options.binary = binary
  cap = DesiredCapabilities().FIREFOX
  cap["marionette"] = True
  cap['loggingPrefs'] = {'driver': 'ALL'}
  driver = webdriver.Firefox(firefox_options=options, capabilities=cap, executable_path="C:\Python\geckodriver.exe")
  
  
  driver.get('https://facebook.com')
  
  time.sleep(2) # time for page to load
  logs = driver.get_log('browser')
  messages = map(lambda l: l['message'], logs)
  has_console_logs = any(map(lambda m: m.find('console log') &gt;= 0, messages))
  print('Success' if has_console_logs else 'Failure')
  driver.quit()
  </code></pre>