我使用的是Firefox 53版.Geckodriver版本0.16,selenium版本3.4。我想要完成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()
控制台输出
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
答案 0 :(得分:2)
已知问题,您可以在此处查看
geckodriver是W3C WebDriver的一个实现,它没有 此时指定一个日志接口,因此这是预期的行为。