Selenium Python Chrome未知错误:DevToolsActivePort文件在Windows 10中不存在

yx2lnoni  于 2023-03-31  发布在  Windows
关注(0)|答案(1)|浏览(236)

我不能解决这个错误,我尝试了一切建议启动 chrome webdriver与我目前的配置文件

Message: unknown error: Chrome failed to start: exited normally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Program Files\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

代码如下

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from pathlib import Path
import time

# initialize the Chrome driver
_options = webdriver.ChromeOptions()
print(str(Path.home())+"/AppData/Local/Google/Chrome/User Data")
_options.add_argument("--user-data-dir=C:/Users/dmitr/AppData/Local/Google/Chrome/User Data")
_options.add_argument('--profile-directory=Default')
_options.add_argument("--no-sandbox")
_options.add_argument("--disable-dev-shm-usage")
#_options.add_argument("--headless")

s = Service('D:\chromedriver')
driver = webdriver.Chrome(service=s, options=_options)

我没有别的办法可以尝试,为什么这不起作用?

5lhxktic

5lhxktic1#

你运行你的编辑器w/管理员权限?当我运行你的代码,它失败了,直到我打开VSCode作为管理员,然后它工作.我使用的ChromeDriver版本111.0.5563.64

相关问题