尽管驱动程序位于/usr/local/bin中,但硒“无法找到匹配的功能集" [英] Selenium “Unable to find a matching set of capabilities” despite driver being in /usr/local/bin

查看:93
本文介绍了尽管驱动程序位于/usr/local/bin中,但硒“无法找到匹配的功能集"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Selenium Webdriver打开firefox浏览器.在进行网络抓取和抓取项目时,/usr/local/bin中已经有我的geckodriver.

I was trying to open the firefox browser using selenium webdriver. I already have my geckodriver in /usr/local/bin as I'm working on project of web scraping and crawling.

  • Geckodriver版本21.0
  • Firefox版本64.0(量子)
  • 硒版本-3.141.0.

还尝试了版本为17.0、19.0、23.0的geckodriver;找到组合.

Also tried geckodriver of versions i.e 17.0,19.0,23.0; to find the combination.

我尝试过的是下面的代码.

What I have tried is in the following code.

from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup

driver=webdriver.Firefox()
driver.get("https://kissanime.ru/")
driver.maximize_window()

在执行代码时,它弹出一个错误:

While executing the code it popped an error:

Traceback (most recent call last):
  File "downloader.py", line 9, in <module>
    driver=webdriver.Firefox()
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
keep_alive=True)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/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

推荐答案

此错误消息...

selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

...表示 GeckoDriver 无法启动/产生新的 WebBrowsing会话,即 Firefox浏览器会话.

...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.

您的主要问题可能是所使用的二进制版本之间的不兼容性,如下所示:

Your main issue may be the incompatibility between the version of the binaries you are using as follows:

  • 升级到当前级别> 版本3.141.59 > .
  • GeckoDriver 升级到 GeckoDriver v0.23.0 级.
  • 确保GeckoDriver位于指定位置.
  • 确保GeckoDriver对非root用户具有可执行权限.
  • Firefox 版本升级到 Firefox v64.0. 级别.
  • 通过 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项.
  • (仅仅WindowsOS )使用 CCleaner 工具,可消除执行 Test Suite 之前和之后的所有操作系统琐事.
  • (仅仅LinuxOS )来卸载. Revo Uninstaller 并安装最新版本的 Web客户端 GA和发行版.
  • 进行系统重启.
  • 在启动WebDriver/WebBrowser会话时,将参数 executable_path GeckoDriver 的绝对路径一起传递,如下所示:

  • Upgrade Selenium to current levels Version 3.141.59.
  • Upgrade GeckoDriver to GeckoDriver v0.23.0 level.
  • Ensure GeckoDriver is present in the specified location.
  • Ensure GeckoDriver is having executable permission for non-root users.
  • Upgrade Firefox version to Firefox v64.0. levels.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Pass the argument executable_path along with the absolute path of the GeckoDriver while initiating the WebDriver/WebBrowser session as follows:

  • Windows操作系统格式:

driver = webdriver.Firefox(executable_path=r'C:\path\to\geckodriver.exe')

  • Linux MAC OS X 格式:

  • Linux and MAC OS X format:

    driver = webdriver.Firefox(executable_path='/path/to/geckodriver')
    

  • 以非root用户身份执行Test.

    Execute your Test as a non-root user.

    这篇关于尽管驱动程序位于/usr/local/bin中,但硒“无法找到匹配的功能集"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆