selenium中 ValueError(f“The browser path is not a valid file: {output[‘browser_path‘]}“)错误解决办法_valueerror: the browser path is not a valid file:
错误收集
There was an error managing chromedriver (error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json)); using driver found in the cache
Traceback (most recent call last):
File \"C:\\Users\\Administrator\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\selenium\\webdriver\\common\\driver_finder.py\", line 75, in _binary_paths
raise ValueError(f\"The browser path is not a valid file: {output[\'browser_path\']}\")
ValueError: The browser path is not a valid file:The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File \"C:\\Users\\Administrator\\PycharmProjects\\selenium_study\\demo.py\", line 8, in
webdriver_do = webdriver.Chrome()
^^^^^^^^^^^^^^^^^^
File \"C:\\Users\\Administrator\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\selenium\\webdriver\\chrome\\webdriver.py\", line 47, in __init__
super().__init__(
File \"C:\\Users\\Administrator\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\selenium\\webdriver\\chromium\\webdriver.py\", line 53, in __init__
if finder.get_browser_path():
^^^^^^^^^^^^^^^^^^^^^^^^^
File \"C:\\Users\\Administrator\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\selenium\\webdriver\\common\\driver_finder.py\", line 47, in get_browser_path
return self._binary_paths()[\"browser_path\"]
^^^^^^^^^^^^^^^^^^^^
File \"C:\\Users\\Administrator\\PycharmProjects\\PythonProject\\.venv\\Lib\\site-packages\\selenium\\webdriver\\common\\driver_finder.py\", line 78, in _binary_paths
raise NoSuchDriverException(msg) from err
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_locationProcess finished with exit code 1
错误分析
这个应该是没有找到谷歌浏览器的路径
解决办法
找到谷歌浏览器官网下载浏览器,下载完毕之后安装
Google Chrome 网络浏览器
- 找到chrome浏览器根目录
- 配置环境变量