selenium.common.exceptions.SessionNotCreatedException: 消息: 无



OS: Ubuntu

我正在遵循本教程的步骤 2.5:

1(我下载了两个版本的Selenium服务器: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上,我收到相同的错误。

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

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

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

最新更新