消息:在实时服务器上加载时使用 Selenium 和 GeckoDriver 无法找到匹配的功能集错误

Message: Unable to find a matching set of capabilities error using Selenium and GeckoDriver while loading on live server

我必须在将使用 selenium 和 firefox 的 linux 网络服务器上构建一个网络应用程序。当我 运行 应用程序 linux 服务器 "localhost:5000" 它工作得很好。但是当我用“127.0.0.1:80”尝试它时,它在 webdriver 加载期间没有给我一个错误:

driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')

错误:

"Message: Unable to find a matching set of capabilities"  

在 nginx access.log 中它产生了一个 http 200 而 error.log 上什么也没有 在 geckodriver.log 它产生:

Listening on port 41209

环境详情:

nginx imageApp.conf

server {
listen 80;
server_name 127.0.0.1;

location / {
    include proxy_params;
    proxy_pass http://unix:/home/administator/imageDetectionApplication/imageDetectionApplication.sock;
    }
}

imageDetectionApplication.service

我是 linux 服务器的新手...!!

这个错误信息...

Message: Unable to find a matching set of capabilities

...意味着 GeckoDriver 无法 initiate/spawn 新的 浏览上下文 Firefox 浏览器 会话。

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

  • 您的 Selenium Client 版本是 3.8.0,几乎比 2.5 年 老。
  • 您的JDK版本对我们来说未知
  • 您的 GeckoDriver 版本是 0.18.0,这是旧版本。
  • 你的 Firefox 版本是 53 也很旧了。

因此 Selenium Client v3.8.0GeckoDriver v0.18.0 之间存在明显的不匹配火狐浏览器 v53


解决方案

确保:

  • JDK 升级到当前等级 JDK 8u251.
  • Selenium 已升级到当前级别 Version 3.141.59
  • GeckoDriver 升级到 GeckoDriver v0.26.0 级别。
  • Firefox 已升级到当前的 Firefox v72.0 级别。
  • GeckoDriver 出现在所需位置。
  • GeckoDriver 拥有非 root 用户的可执行权限。
  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖。
  • 如果您的基础 Web Client 版本太旧,则卸载它安装最新的 GA 和发布版本的 Web Client
  • 系统重启
  • 以非 root 用户身份执行 Test
  • 始终在 tearDown(){} 方法中调用 driver.quit() 以优雅地关闭和销毁 WebDriverWeb Client 实例.

参考资料

您可以在以下位置找到一些相关讨论:

  • Selenium WebDriver, Firefox, Centos, unable to find a matching set of capabilities
  • Unable to find a matching set of capabilities with selenium 3.4.3, firefox 54.0 and gecko driver 0.17
  • selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities with GeckoDriver, Selenium and Firefox