用seleniumPython驱动器Opera

我添加到我的环境变量

SELENIUM_SERVER_JAR = C:\selenium_drivers\selenium-server-standalone.jar

我在这里下载的http://selenium-

release.storage.googleapis.com/index.html?path=2.46/

Python脚本:

from selenium import webdriver

webdriver.Opera()

输出:

13:37:37.906 INFO - Launching a standalone Selenium Server

13:37:38.104 INFO - Java: Oracle Corporation 25.45-b02

13:37:38.104 INFO - OS: Windows 8 6.2 x86

13:37:38.132 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2

13:37:38.269 INFO - Driver class not found: com.opera.core.systems.OperaDriver

13:37:38.275 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered

13:37:38.630 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:53024/wd/hub

13:37:38.631 INFO - Selenium Server is up and running

13:37:47.892 INFO - Executing: [new session: Capabilities [{browserName=opera, javascriptEnabled=true, version=, platform=ANY}]])

13:37:47.907 INFO - Creating a new session for Capabilities [{browserName=opera, javascriptEnabled=true, version=, platform=ANY}]

Started InternetExplorerDriver server (32-bit) 2.43.0.0

Listening on port 43192

13:37:51.090 INFO - Done: [new session: Capabilities [{browserName=opera, javascriptEnabled=true, version=, platform=ANY}]]

我期望jar定义了所有内容,为什么找不到驱动程序类?

回答:

根据您的问题,您似乎正在使用适用于Opera 12及更高版本的旧驱动程序。假设您尝试使用最新版本的Opera,则需要使用以下站点上提供的驱动程序:

OperaChromiumDriver

该站点列出了示例python代码,我已经确认它们可以在我的机器上打开并驱动Opera:

OperaChromiumDriver的Python示例

import time

from selenium import webdriver

from selenium.webdriver.chrome import service

webdriver_service = service.Service('C:\\Users\\Kris\\Downloads\\WinPython-32bit-2.7.9.2\\operadriver.exe')

webdriver_service.start()

driver = webdriver.Remote(webdriver_service.service_url, webdriver.DesiredCapabilities.OPERA)

driver.get('https://www.google.com/')

input_txt = driver.find_element_by_name('q')

input_txt.send_keys('operadriver\n')

time.sleep(5) #see the result

driver.quit()

查看硒的更改日志,似乎在2.45之后不再支持基于Presto的Operas,这就是为什么您收到错误消息的原因:CHANGELOG

以上是 用seleniumPython驱动器Opera 的全部内容, 来源链接: utcz.com/qa/402089.html

回到顶部