简体   繁体   中英

When I try to use Selenium with python to open a Chrome browser, windows gives me a FileNotFoundError: [WinError 2]

Here is my code:

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

Then in windows PowerShell I get:

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

Do I need to add something to PATH?

You need to have the chromedriver executable in your PATH . Go here to get more information and to download chromedriver for various platforms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM