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 yourPATHsetting 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 启动
基础教程推荐
- 对多索引数据帧的列进行排序 2022-01-01
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
