用硒Python驱动器Opera [英] Drive Opera with selenium python

查看:115
本文介绍了用硒Python驱动器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已定义了所有内容,为什么找不到驱动程序类?

I was expecting jar to have everything defined, why do I get Driver class not found?

推荐答案

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

Based on your question it looks like you are using an old driver for Opera version 12 and older. Assuming that you're trying to use the most recent version of Opera you'll want to use the driver available at the following site: OperaChromiumDriver

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

The site lists sample python code which I have confirmed works on my machine to open and drive Opera: Python Examples for OperaChromiumDriver

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,这就是为什么您收到错误消息的原因:

Looking into the change logs for selenium it looks like support for Presto-based Operas was discontinued after 2.45 which is why you're getting the error messages:CHANGELOG

这篇关于用硒Python驱动器Opera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆