首页 > 解决方案 > 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```

标签: seleniumgoogle-chromeselenium-webdriver

解决方案


这个错误:

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,这应该可以帮助您解决此问题。


推荐阅读