zoukankan      html  css  js  c++  java
  • ubuntu系统下selenium打开火狐浏览器提示'Unable to find a matching set of capabilities.和Message: connection refused

    环境:

    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-67.0.4.tar.bz2

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

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

    root@yanner-VirtualBox:/home/yanner/下载/firefox# sudo apt-get install firefox
    更新后,Firefox 52.0.2

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

    from selenium import webdriver
    browser = webdriver.Firefox()

    但是,打开网页失败,提示Message: connection refused:

    from selenium import webdriver
    browser = webdriver.Firefox()
    browser.get("http://www.baidu.com")
    browser.find_element_by_id("kw").send_keys("selenium")
    browser.find_element_by_id("su").click()
    browser.quit()

    研究了半天,将驱动geckodriver-v0.24.0-linux32降版本,将目录/usr/local/bin下的驱动geckodriver删掉,下载了geckodriver-v0.17.0-linux32解压复制到/usr/local/bin下(可以参考上一篇文章https://www.cnblogs.com/yanner/p/11077762.html),

    再次运行上面的脚本,正常打开!

  • 相关阅读:
    oracle 11.2.0.4 ADG+linux+补丁升级11.2.0.4.181016(28204707)
    审计信息清理及审计表迁移时遇到的坑
    与其他schema下表同名视图实验
    Oracle 11gr2 RAC到单实例的DG搭建(落地备份)
    Oracle数据文件名乱码问题
    Vmware12+centos7:固定IP
    Vmware12+OracleLinux5.4+Oracle 11.2.0.3+ASM
    OracleLinux文件名最后带空格生成了新的文件???
    OGG新增DataPump进程下发(多个进程共用队列文件)
    OGG BIGDATA从版本12.2升级到12.3.2.1.1
  • 原文地址:https://www.cnblogs.com/yanner/p/11081861.html
Copyright © 2011-2022 走看看