简体   繁体   English

Selenium Chromedriver错误代码:3221225477

[英]Selenium Chromedriver error code : 3221225477

When initiating chromedriver with selenium in python 3, everything seems to go okay for at least one second while it loads, but then this error message pops up : 在python 3中用硒启动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

My current code is : 我当前的代码是:

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')

... I've tried using an absolute path for the chromedriver location, but that still doesn't help (the chromedriver.exe file is located in the same directory as the script) ...我尝试为chromedriver位置使用绝对路径,但这仍然无济于事(chromedriver.exe文件与脚本位于同一目录中)

  • I'm running this on python 3.6.5 on a Windows 10 laptop 我在Windows 10笔记本电脑上的python 3.6.5上运行

  • I've already been searching around on the web for about 3 hours but haven't come across the same error status code that I'm getting. 我已经在网上搜索了大约3个小时,但是没有遇到与我得到的相同的错误状态代码。

Okay, this is really weird. 好吧,这真的很奇怪。 Chromedriver selenium worked perfectly when launching it in an interactive shell, but not when executing the script. Chromedriver selenium在交互式外壳中启动时效果很好,但在执行脚本时效果不佳。 On my machine, I've setup a few batch files which are executed when a python script is executed (to run things like Ansicon.exe for colour display in cmd), and after running the python script with the command 'python3 script.py' it works perfectly... So I'm not sure why it didn't before, but anyhow, it's fixed now. 在我的机器上,我设置了一些批处理文件,这些批处理文件在执行python脚本时运行(运行诸如Ansicon.exe之类的命令,以便在cmd中进行彩色显示),并在使用命令'python3 script.py运行python脚本后执行'它工作得很好...所以我不确定为什么以前没有,但是无论如何,现在已经解决了。

  • But if anyone does have an answer, I'd love to know why this happened... 但是,如果有人有答案,我很想知道为什么会这样...

My code is now : 我的代码现在是:

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

and the batch file to start is one line : 并且要启动的批处理文件为一行:

python3 script.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM