【问题标题】:Chrome crashes after launching [Selenium] [Python]Chrome 在启动 [Selenium] [Python] 后崩溃
【发布时间】:2017-01-15 06:56:53
【问题描述】:

我编写了一个小脚本来加载我的默认 Chrome 配置文件并使用 Selenium 打开一个站点。但是,chrome成功启动后,代码会暂停一段时间,然后崩溃。

我的脚本:

    options = webdriver.ChromeOptions() 
    options.add_argument("--user-data-dir=C:\\Users\\hbur3\\AppData\\Local\\Google\\Chrome\\User Data") 
    options.add_argument("--start-maximized");
    wd = webdriver.Chrome(chrome_options=options)
    wd.get("https://google.com.au/")

Python 错误:

  selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.14393 x86_64)

Chrome 驱动程序日志:

[2.638][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-component-extension="C:\Users\hbur3\AppData\Local\Temp\scoped_dir21208_8173\internal" --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12638 --safebrowsing-disable-auto-update --start-maximized --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\hbur3\AppData\Local\Google\Chrome\User Data"
    [2.641][DEBUG]: DevTools request: http://localhost:12638/json/version
    [4.644][DEBUG]: DevTools request failed
    [4.695][DEBUG]: DevTools request: http://localhost:12638/json/version
    [4.896][DEBUG]: DevTools request failed
    [4.946][DEBUG]: DevTools request: http://localhost:12638/json/version
    [6.699][DEBUG]: DevTools request failed
    [6.750][DEBUG]: DevTools request: http://localhost:12638/json/version
    [6.950][DEBUG]: DevTools request failed
        etc...

我尝试了各种解决方案,包括:

  • 重新安装 Chrome 驱动程序
  • 创建新的 Chrome 用户配置文件
  • 将默认配置文件复制到别处
  • 仅在没有打开其他 Chrome 窗口时运行

我不愿意删除我的个人资料并重新安装 Chrome,但这可能是我唯一的解决方案。

【问题讨论】:

    标签: python google-chrome selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    我认为你需要做你害怕的事情......看这个answer。您可以export 并导入您的个人资料以节省时间。

    您可以尝试的另一件事是启动RemoteWebDriver 而不是ChromeDriver。首先运行chromedriver.exe,然后连接到它:

    from selenium import webdriver
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    driver = webdriver.Remote(
    command_executor='http://localhost:9515/',
    desired_capabilities=DesiredCapabilities.CHROME)
    

    如果您的问题仍然存在,请寻找打开的issue 或者打开一个新的。

    【讨论】:

    • 已修复!谢谢。
    猜你喜欢
    • 2020-06-23
    • 2021-06-10
    • 2016-03-13
    • 1970-01-01
    • 2022-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    相关资源
    最近更新 更多