【问题标题】:selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: OperaDriverServiceselenium.common.exceptions.SessionNotCreatedException:消息:无法创建新服务:OperaDriverService
【发布时间】:2019-01-14 09:46:55
【问题描述】:

操作系统:Ubuntu

我关注step 2.5 of this tutorial:

1) 我下载了两个版本的 selenium server Standalone:selenium-server-standalone-2.50.1.jarselenium-server-standalone-3.13.0.jar

2) 我创建了一个名为 test_selenium_server.py 的文件:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(
   command_executor='http://127.0.0.1:4444/wd/hub',
   desired_capabilities=DesiredCapabilities.CHROME)

driver = webdriver.Remote(
   command_executor='http://127.0.0.1:4444/wd/hub',
   desired_capabilities=DesiredCapabilities.OPERA)

driver = webdriver.Remote(
   command_executor='http://127.0.0.1:4444/wd/hub',
   desired_capabilities=DesiredCapabilities.HTMLUNITWITHJS)

我安装了 chromedriver 和 geckodriver。

当我运行java -jar selenium-server-standalone-2.50.1.jar 然后python test_selenium_server.py 时,我收到如下错误:

Traceback (most recent call last):
  File "test_selenium_server.py", line 12, in <module>
    desired_capabilities=DesiredCapabilities.OPERA)
...
selenium.common.exceptions.WebDriverException: Message: The best matching driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver can't create a new driver instance for Capabilities [{browserName=opera, version=, platform=ANY}]
Build info: version: '2.50.1', revision: 'd7fc91b', time: '2016-01-29 19:08:26'
System info: host: 'AMDC2763', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-30-generic', java.version: '1.8.0_181'
Driver info: driver.version: unknown
...

当我运行java -jar selenium-server-standalone-3.13.0.jar 然后python test_selenium_server.py 时,我收到如下错误:

Traceback (most recent call last):
  File "test_selenium_server.py", line 12, in <module>
    desired_capabilities=DesiredCapabilities.OPERA)
...
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to create new service: OperaDriverService
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:19.891Z'
System info: host: 'AMDC2763', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-30-generic', java.version: '1.8.0_181'
Driver info: driver.version: unknown
...

我已经尝试了 python2 和 python3(它们给出了相同的错误)并搜索了一半的互联网,但一无所获。我相信有一个问题导致了这些错误,这就是我在这里显示两条错误消息的原因。请帮忙。

编辑:在 MacOS High Sierra 上,我遇到了同样的错误。

【问题讨论】:

  • 为什么在本地机器上测试时使用远程?
  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。避免一次问多个不同的问题。请参阅How to Ask 页面以获得澄清此问题的帮助。
  • @HamzaTorjmen,我只是按照教程进行操作,想知道为什么它不起作用。
  • @DebanjanB,恐怕我觉得我的问题不够有限。
  • @ibodi 2 个硒版本 2.50.13.13.0; 2 个 Python 版本 python2python3;还是要说够有限

标签: python selenium selenium-webdriver opera


【解决方案1】:

堆栈跟踪告诉我您尚未将 Opera 注册到您的(远程)本地 selenium 服务器。

您提到的教程提供了 3 个不同 示例来启动不同类型的会话。

该教程似乎没有提到如何告诉您的服务器您有歌剧(并且可能与 selenium-python 无关,因为它对 selenium 是通用的,并且与客户端 python 绑定无关)。 如果您需要测试多个浏览器,我建议您将服务器启动为 Selenium Grid,描述为 here。你可以给它注册一个 Opera 节点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 2019-12-19
    • 1970-01-01
    • 2020-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多