gpt4 book ai didi

python - 用 selenium python 驱动 Opera

转载 作者:行者123 更新时间:2023-11-28 21:51:01 26 4
gpt4 key购买 nike

我添加到我的环境变量中

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: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()

编辑:查看 selenium 的更改日志,看起来对基于 Presto 的 Operas 的支持在 2.45 之后停止,这就是您收到错误消息的原因:CHANGELOG

关于python - 用 selenium python 驱动 Opera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31055124/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com