【问题标题】:Selenium Chromedriver error code : 3221225477Selenium Chromedriver 错误代码:3221225477
【发布时间】:2019-04-06 02:21:39
【问题描述】:

在 python 3 中使用 selenium 启动 chromedriver 时, 加载时一切似乎都正常至少一秒钟, 但随后弹出此错误消息:

Traceback (most recent call last):
  File "C:\...\Selenium\UsingChrome.py3", line 15, in <module>
    driver = webdriver.Chrome(executable_path="chromedriverwin32.exe")
  File "c:\Users\...\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "c:\Users\...AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 98, in start
    self.assert_process_still_running()
  File "c:\Users\...\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service chromedriverwin32.exe unexpectedly exited. Status code was: 3221225477

我当前的代码是:

from selenium import webdriver
import time, os

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = 'chromedriver.exe'
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://python.org')

...我尝试使用绝对路径作为 chromedriver 位置,但这仍然没有帮助(chromedriver.exe 文件与脚本位于同一目录中)

  • 我在 Windows 10 笔记本电脑上的 python 3.6.5 上运行它

  • 我已经在网上搜索了大约 3 个小时,但没有遇到与我得到的相同的错误状态代码。

【问题讨论】:

    标签: python python-3.x selenium selenium-chromedriver


    【解决方案1】:

    好吧,这真的很奇怪。 Chromedriver selenium 在交互式 shell 中启动时运行良好,但在执行脚本时却不行。 在我的机器上,我设置了一些批处理文件,这些文件在执行 python 脚本时执行(运行诸如 Ansicon.exe 之类的东西以在 cmd 中显示颜色),并在使用命令“python3 script.py”运行 python 脚本之后'它完美地工作...... 所以我不知道为什么以前没有,但无论如何,它现在已经修复了。

    • 但如果有人有答案,我很想知道为什么会这样......

    我的代码现在是:

    from selenium import webdriver
    browser = webdriver.Chrome()
    while 1: pass # wait forever just to let chromedriver be interactive
    

    并且要启动的批处理文件是一行:

    python3 script.py
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-06
      • 1970-01-01
      • 2018-04-29
      • 1970-01-01
      • 2016-07-24
      • 2020-09-16
      相关资源
      最近更新 更多