python在用selenium調Firefox時報錯:python
Traceback (most recent call last):
File "G:\python_work\chapter11\test_selenium_firefox.py", line 10, in <module>
driver = webdriver.Firefox()
File "C:\Python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 154, in __init__
keep_alive=True)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilitiesweb
=============================session
python版本3.4.3 , selenium版本3.4.3 , Firefox版本49.0.測試
報錯的緣由是python, selenium, Firefox之間的版本兼容問題 , 將Firefox升級到最新版55.0後問題解決.spa
同時selenium在調用Firefox時須要geckodriver , 下載後添加到Firefox安裝目錄, 同時添加Firefox安裝目錄到系統環境變量Path.firefox
=============================code
測試代碼:blog
1 from selenium import webdriver 2 3 driver = webdriver.Firefox() 4 driver.get("http://www.baidu.com")