selenium - Python Selenuim 崩溃
问题描述
当我运行我的代码时它崩溃了,请帮忙,这是在深夜制作的,所以我可能错过了一些 obv。我没有像我的其他程序那样启动 chrome 驱动程序,而是让它运行实际的 chrome。有解决办法吗?
from selenium.webdriver.common.proxy import Proxy, ProxyType
import time
# change 'ip:port' with your proxy's ip and port
proxy_ip_port = '95.217.168.246:8888'
proxy = Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy.http_proxy = proxy_ip_port
proxy.ssl_proxy = proxy_ip_port
capabilities = webdriver.DesiredCapabilities.CHROME
proxy.add_to_capabilities(capabilities)
# replace 'your_absolute_path' with your chrome binary absolute path
driver = webdriver.Chrome(r'C:\Users\andre\Desktop\Python dsicord bot\chromedriver',
desired_capabilities=capabilities)
driver.get('http://whatismyipaddress.com')
time.sleep(8)```
**Error:**
```DevTools listening on ws://127.0.0.1:57598/devtools/browser/120e371a-b935-4d04-9057-de3f728ce8b0
Traceback (most recent call last):
File "c:\Users\andre\Desktop\Python dsicord bot\sys.py", line 17, in <module>
driver = webdriver.Chrome(r'C:\Users\andre\Desktop\Python dsicord bot\chromedriver',
File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\andre\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 93
Current browser version is 92.0.4515.159 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe```
解决方案
这个错误:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created:This version of ChromeDriver only supports Chrome version 93
基本上是你没有兼容版本的浏览器和浏览器驱动。
截至 2021 年 8 月 29 日
Latest stable release: ChromeDriver 92.0.4515.107
而谷歌 chrome 浏览器版本是Version 92.0.4515.159 (Official Build) (64-bit)
chromedriver 的下载链接,尝试获取 92.0,这应该可以帮助您解决此问题。
推荐阅读
- linux - 无法通过 bash 脚本登录到 postgres
- algorithm - 在并联直流电路计算方面需要帮助?
- asp.net-core - 如何在 ASP.NET Core 3.1 中缓存 404 响应的输出?
- c++ - 将 python 与 C++ 集成
- jmeter - JMeter 插件:测试计划检查器无法在 Windows 上检测到 cmdrunner-2.2.jar
- java - 如何使用 selenium 自动化 facebook 注册页面?
- reactjs - 如何更改 Web 应用程序中的 FCM 推送通知图标
- java - Jboss服务停止,日志中没有任何错误
- android - 使用改造从 api 获取回收站视图中的图像和名称在应用程序 android studio 中显示空白屏幕
- reactjs - 通过 React 测试库 (RTL) 触发 react-ace onChange