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

Selenium 4.13.0初始化Chrome驱动卡顿,无法启动应用程序

解决Selenium启动Chrome卡顿无法运行的问题

核心错误原因

你错误地将Chrome浏览器的可执行文件路径(chrome.exe)传给了Service类,而Service需要的是ChromeDriver的路径,这是导致程序卡顿无法启动的根本原因。

修复步骤

  1. 下载匹配版本的ChromeDriver
    必须下载与你的Chrome浏览器版本(118.0.5993.70)完全一致的ChromeDriver,适配Win64系统。

  2. 修改代码中的Service路径
    将Service的参数改为ChromeDriver的可执行文件路径,示例:

    s = Service('executables/chrome-win64/chromedriver.exe')
    
  3. 修正后的完整代码

    from selenium import webdriver
    from selenium.webdriver.chrome.service import Service
    
    # 注意:这里是chromedriver.exe的路径,不是chrome.exe
    s = Service('executables/chrome-win64/chromedriver.exe')
    
    chromeOptions = webdriver.ChromeOptions()
    chromeOptions.add_argument("--start-maximized")
    # 可选:添加--no-sandbox参数解决部分环境启动问题
    chromeOptions.add_argument("--no-sandbox")
    
    driver = webdriver.Chrome(service=s, options=chromeOptions)
    print("Hello.....")
    driver.get("https://chromedriver.chromium.org/downloads")
    
    driver.quit()  # 建议用quit()代替close(),确保完全退出驱动进程
    

额外排查点

  • 确认ChromeDriver与Chrome版本严格对应,版本不匹配会引发启动异常。
  • 检查文件路径是否正确,相对路径需保证程序能正确定位到文件。
  • 若仍有问题,可尝试以管理员权限运行程序,或临时关闭系统防火墙/杀毒软件的拦截。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 11:25:25