python中用selenium调Firefox报错问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python中用selenium调Firefox报错问题相关的知识,希望对你有一定的参考价值。
python在用selenium调Firefox时报错:
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 capabilities
=============================
python版本3.4.3 , selenium版本3.4.3 , Firefox版本49.0.
报错的原因是python, selenium, Firefox之间的版本兼容问题 , 将Firefox升级到最新版55.0后问题解决.
同时selenium在调用Firefox时需要geckodriver , 下载后添加到Firefox安装目录, 同时添加Firefox安装目录到系统环境变量Path.
=============================
测试代码:
1 from selenium import webdriver 2 3 driver = webdriver.Firefox() 4 driver.get("http://www.baidu.com")
以上是关于python中用selenium调Firefox报错问题的主要内容,如果未能解决你的问题,请参考以下文章
python+selenium3+firefox中使用ActionChains双击等鼠标事件操作报错,但是其它谷歌、ie等浏览器均正常。