当我尝试使用Selenium和python打开Chrome浏览器时,windows会给我一个FileNotFoundError:[WinError 2]

时间:2016-01-29 22:34:35

标签: python google-chrome selenium

这是我的代码:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com/")

然后在Windows PowerShell中我得到:

PS C:\Users\userName\PycharmProjects\untitled> python .\s_Chrome.py
Traceback (most recent call last):
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium-2.49.2-py3.5.egg\selenium\webdriver\common\service.py", line 62,
in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\subproce
ss.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\userName\AppData\Local\Programs\Python\Python35-32\lib\subproce
ss.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

我是否需要向PATH添加内容?

1 个答案:

答案 0 :(得分:0)

您需要chromedriver中的PATH可执行文件。转到here获取更多信息,并下载各种平台的chromedriver。