问题
I am using Firefox version 53. Geckodriver version 0.16, selenium version 3.4. I want totake console logs of webdriver
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
d = DesiredCapabilities.FIREFOX
d['loggingPrefs'] = {'browser': 'ALL'}
driver = webdriver.Firefox(capabilities=d)
driver.set_window_size(1280,1024)
driver.get('http://google.com')
try:
for entry in driver.get_log('browser'):
print entry
finally:
driver.quit()
Console output
C:\Python27\python.exe C:/Users/GS-0758/PycharmProjects/untitled1/test.py
Starting selenium session
Traceback (most recent call last):
File "C:/Users/GS-0758/PycharmProjects/untitled1/test.py", line 5, in <module>
driver = webdriver.Firefox(capabilities=d)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 153, in __init__
keep_alive=True)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 99, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 189, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 253, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: loggingPrefs was not a the name of a known capability or a valid extension capability
回答1:
It's known issue, you can check it here
geckodriver is an implementation of W3C WebDriver which doesn’t specify a log interface at the moment, so this is expected behaviour.
https://github.com/mozilla/geckodriver/issues/330
来源:https://stackoverflow.com/questions/44196421/not-able-to-get-console-logs-on-firefox-webdriver