Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python selenium.common.exceptions.SessionNotCreatedException:消息:无法创建新服务:OperaDriverService_Python_Selenium_Selenium Webdriver_Opera - Fatal编程技术网

Python selenium.common.exceptions.SessionNotCreatedException:消息:无法创建新服务:OperaDriverService

Python selenium.common.exceptions.SessionNotCreatedException:消息:无法创建新服务:OperaDriverService,python,selenium,selenium-webdriver,opera,Python,Selenium,Selenium Webdriver,Opera,操作系统:Ubuntu 我的发言如下: 1) 我下载了selenium server standalone的两个版本:selenium-server-standalone-2.50.1.jar和selenium-server-standalone-3.13.0.jar 2) 我创建了一个名为test_selenium_server.py的文件: from selenium import webdriver from selenium.webdriver.common.desired_capabi

操作系统:Ubuntu

我的发言如下:

1) 我下载了selenium server standalone的两个版本:
selenium-server-standalone-2.50.1.jar
selenium-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\u-selenium\u-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
...
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个不同的示例来启动不同类型的会话

该教程似乎没有提到如何告诉您的服务器您有opera(可能与selenium python无关,因为它是selenium的泛型,与客户端python绑定无关)。
如果您需要测试多个浏览器,我建议您将服务器作为Selenium网格启动,如上所述。您可以向其注册Opera节点。

在本地计算机上进行测试时,为什么要使用remote?请编辑问题,将其限制为特定问题,并提供足够详细的信息,以确定适当的答案。避免同时问多个不同的问题。请参阅页面以获取澄清此问题的帮助。@HamzaTorjmen,我只是在学习教程,不知道为什么它不起作用。@DebanjanB,恐怕我发现我的问题不够有限。@ibodi 2 selenium版本
2.50.1
3.13.0
;2个Python版本
python2
python3
;还是要说有限不够?