解决“selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set ...

selenium 启动firefox浏览器时,报错:selenium.common.exceptions.SessionN otCreatedException: Message: Unable to find a matching set of capabilities

原因:如果出现如上信息,说明firefox浏览器版本和浏览器驱动版本不匹配。我环境:firefox49.0.2版本 geckodriver v0.19.0 ,其原因是驱动版本太高(一般都是驱动版本较高)。

解决方法:
1.更换较低版本geckodriver驱动,下载链接 https://github.com/mozilla/geckodriver/releases
在Linux下,一般下载v0.15.0版本的驱动器就可以解决问题,其他版本可以自己试试
2.将驱动压缩包解压,将geckodriver.exe 放在python和火狐浏览器安装目录下 //这两个目录都已经添加至环境变量(在Linux下只需将exe放到python安装目录,现在Windows也只需要把geckodriver.exe放到python目录)。
3.重启浏览器,运行python脚本启动浏览器。
我成功运行的环境:
浏览器版本:49.0.2 //可安装firebug、firexpath、最新版本不兼容。
驱动:geckodriver-v0.15.0-win32
selenium: 3.13.0 (目前最新)
python: 3.6.5

猜你喜欢

转载自blog.csdn.net/qq_34803821/article/details/86653325