ubuntu系统下selenium打开火狐浏览器提示'Unable to find a matching set of capabilities.解决方法

Posted yanner

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu系统下selenium打开火狐浏览器提示'Unable to find a matching set of capabilities.解决方法相关的知识,希望对你有一定的参考价值。

环境:

1、ubuntu系统

2、selenium 3.141.0

3、火狐浏览器驱动 geckodriver-v0.24.0-linux32

在Python中执行脚本:

from selenium import webdriver
browser = webdriver.Firefox()

结果提示:Message: Unable to find a matching set of capabilities

Traceback (most recent call last):
  File "/home/yanner/seleniumtest/sousuo.py", line 2, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

解决方法:更新firefox浏览器

1、从浏览器进入firefox官网下载最新版本Firefox-latest.tar.bz2

2、进入下载目录,将该文件解压。

3、打开终端模拟器,进入到下载目录,输入安装命令行。

[email protected]:/home/yanner/下载/firefox# sudo apt-get install firefox
更新后,Firefox 52.0.2

再次执行脚本,正常打开浏览器。

以上是关于ubuntu系统下selenium打开火狐浏览器提示'Unable to find a matching set of capabilities.解决方法的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu下火狐网页字体如何修改?

Python+Selenium打开火狐浏览器为啥是出现报错呢

为啥我用ubuntu的火狐上不去百度

用selenium打开了火狐浏览器但是为啥会闪退

firefox 打开 selenium ide怎么用

如何打开火狐浏览器的selenium