Chrome驱动程序无法启动

w7t8yxp5  于 2023-02-17  发布在  Go
关注(0)|答案(1)|浏览(948)

我正在使用最新版本的Chromedriver,但是它似乎无法启动,当我尝试用它启动测试时,它只是加载到一个空白屏幕,显示“数据;”,并在调试控制台中打印此命令:

====== WebDriver manager ======
Get LATEST chromedriver version for google-chrome 109.0.5414
Driver [C:\Users\Peter.[redacted]\.wdm\drivers\chromedriver\win32\109.0.5414\chromedriver.exe] found in cache
[ FAIL ] WebDriverException: 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.)

[ FAIL ] AttributeError: 'NoneType' object has no attribute 'close'

我试过删除chromedriver的版本,手动下载并替换可执行文件,卸载并重新安装webdriver-manager,也试过不同版本的webdriver-manager。除了切换到其他webdriver如firefox或remote-chrome外,没有任何效果,但这两个都与我们使用的其他库冲突,所以它们不是选项。任何帮助都将不胜感激。

vcirk6k6

vcirk6k61#

此错误通常发生在Google Chrome浏览器、Chromedriver和/或Selenium版本之间不兼容时。以下是一些可能有助于解决此问题的建议:
请确保您使用的是最新版本的Google Chrome浏览器,并且它与您正在使用的Chrome驱动程序版本兼容。
请确保您使用的Chromedriver版本与您使用的Selenium版本兼容。请确保它们已更新到最新版本。
尝试在Chrome配置中将“disable-dev-shm-usage”属性设置为true。这有助于避免共享内存使用问题。示例:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)

请尝试明确指定Chrome可执行文件的路径,而不是使用默认路径。例如:

from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = '/path/to/chrome'
driver = webdriver.Chrome(options=chrome_options)

相关问题