user6251386
user6251386

Reputation: 11

Capturing console log output from Firefox using Selenium webdriver python bindings

We have a webpage where it logs the output using console.log() method. I am trying to automate it using selenium webdriver Python bindings. I read about the "driver.get_log('browser')" and used it, but it only displays the JavaScript error messages and does not obtain the actual output logged in the console.

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities   
d = DesiredCapabilities.FIREFOX
d['loggingPrefs'] = { 'browser':'ALL' }
fp = webdriver.FirefoxProfile()
driver = webdriver.Firefox(capabilities=d,firefox_profile=fp)
for entry in driver.get_log('browser'):
    print entry

I do not want the error logs in console. I want the actual output of the webpage displayed in browser console.

Upvotes: 1

Views: 4924

Answers (1)

jonasberg
jonasberg

Reputation: 1933

This seems to be a known bug in Selenium and/or Firefox. See issue https://github.com/SeleniumHQ/selenium/issues/1161

It seems to work fine for the Chrome driver, if it helps anyone.

Upvotes: 2

Related Questions