Getting Chrome to launch via Selenium(让 Chrome 通过 Selenium 启动)
问题描述
我在从 python 中的 selenium 获取 Chrome 浏览器实例时遇到问题.我使用的是 Windows 8.我已经下载了 chromedriver 二进制文件并将其添加到我的路径中,但在 Python 中出现以下错误:
I am having issues getting an instance of a Chrome browser from selenium in python. I'm using Windows 8. I have downloaded the chromedriver binary and added it to my path but I get the following error in Python:
selenium.common.exceptions.WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.
以下行出现此错误:
driver = webdriver.Chrome(executable_path='path ochromedriver_win32_2.0')
推荐答案
两种设置方式,你搞混了.
Two ways to set it, you somehow mixed up.
将
chromedriver.exe
的路径放入PATH
(在 Windows 上),这样您的PATH
设置是正确的,但是你需要调用默认构造函数.
Put the
chromedriver.exe
's path intoPATH
(on Windows), so yourPATH
setting is correct, but you need to call the default constructor.
driver = webdriver.Chrome()
在 webdriver.Chrome(executable_path='some path')
中指定路径.这里需要的是可执行文件的完整路径,而不是目录.
Specify the path in webdriver.Chrome(executable_path='some path')
. Here you need the full path to the executable, not the directory.
webdriver.Chrome(executable_path=r'C:UsersHaranKumarDownloadschromedriver_win32_2.0chromedriver.exe')
选择你想要的任何一个.
Choose either one you want.
这篇关于让 Chrome 通过 Selenium 启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:让 Chrome 通过 Selenium 启动


基础教程推荐
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 包装空间模型 2022-01-01