python
system_error
ai_generated
true
selenium.common.exceptions.WebDriverException: 消息: 'chromedriver' 可执行文件需要在 PATH 中
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
ID: python/pytest-selenium-webdriver-error
80%修复率
89%置信度
0证据数
2024-04-17首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 4.x | active | — | — | — |
根因分析
Selenium 无法找到 ChromeDriver 可执行文件。这发生在 ChromeDriver 未安装、不在 PATH 中,或版本与已安装的 Chrome 浏览器不匹配时。
English
Selenium cannot find the ChromeDriver executable. This occurs when ChromeDriver is not installed, not in PATH, or the version does not match the installed Chrome browser.
解决方案
-
95% 成功率
from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
-
92% 成功率
from selenium import webdriver driver = webdriver.Chrome() # Auto-downloads driver
无效尝试
常见但无效的做法:
-
80% 失败
This makes tests non-portable and breaks on other machines or CI environments with different paths.
-
70% 失败
This works locally but is not reproducible. The driver may be outdated or incompatible with the browser version.