I'm trying to get a web page's console.log
output from Firefox via the python Selenium API bindings. Based on the code for Chrome, and some advice from the documentation, I tried the following:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
d = DesiredCapabilities.FIREFOX
d['loggingPrefs'] = { 'browser':'ALL' }
fp = webdriver.FirefoxProfile()
fp.set_preference('webdriver.log.file', '/tmp/firefox_console')
driver = webdriver.Firefox(capabilities=d,firefox_profile=fp)
driver.set_window_size(1280,1024)
driver.get('http://foo.com')
try:
WebDriverWait(driver,10).until(lambda driver: driver.execute_script("return document.readyState") == "complete")
for entry in driver.get_log('browser'):
print entry
finally:
driver.quit()
But, for even a simple example page that calls console.log("foo")
, I don't see "foo"
either in the log entries returned via the API or in the /tmp/firefox_console
file. Am I doing something wrong? Or is this a Selenium limitation?