You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Selenium启动网站时Chrome浏览器崩溃问题求助

Selenium Chrome启动问题解决方案

常见问题修复步骤

1. ChromeDriver与Chrome版本不匹配

这是最常见的故障原因,ChromeDriver版本必须和本地安装的Chrome浏览器大版本完全一致。

  • 查看Chrome版本:打开Chrome → 右上角三点菜单 → 帮助 → 关于Google Chrome,获取版本号(如125.0.6422.112)
  • 下载对应版本ChromeDriver:获取同大版本的驱动文件
  • 替换代码中的驱动路径为新文件路径

2. 驱动路径错误

检查代码中Service的路径是否正确:

  • Windows路径可使用正斜杠/或双反斜杠\\,避免单反斜杠转义问题
  • 示例路径写法:
s=Service('C:/Users/Morteza/Documents/Dev/chromedriver.exe')
# 或
s=Service('C:\\Users\\Morteza\\Documents\\Dev\\chromedriver.exe')

3. 权限问题

  • 确保ChromeDriver文件有可执行权限:右键文件 → 属性 → 安全,确认当前用户拥有读取和执行权限
  • 尝试以管理员身份运行脚本

4. 自动管理ChromeDriver(推荐)

使用webdriver-manager库自动匹配驱动版本,避免手动下载的麻烦:

  1. 安装依赖库:
pip install webdriver-manager
  1. 修改代码:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

browser = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
url='https://www.google.com'
browser.get(url)

内容的提问来源于stack exchange,提问作者Daniel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 00:35:26