0 votes
1 view
in Devops and Agile by (19.8k points)

I'm beginning the automate the boring stuff book and I'm trying to open a chrome web browser through python. I have already installed selenium and

I have tried to run this file:

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()


But because of that I get this Error:

Traceback (most recent call last):   File "C:\Program Files


 line 74, in start

     stdout=self.log_file, stderr=self.log_file)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__

     restore_signals, start_new_session)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child

     startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:/Program Files

(x86)/Python36-32/test.py", line 5, in <module>

    browser = webdriver.Chrome()   File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py",

line 62, in __init__

   self.service.start()   File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py",

line 81, in start

   os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver'

  executable needs to be in PATH. Please see


1 Answer

0 votes
by (63.4k points)

You need to specify the path where your chromedriver is located.

  1. Download chromedriver for your desired platform from here.

  2. Setup chromedriver on your system path, or wherever your code is.

  3. If not using a system path, link your chromedriver.exe (For non-Windows users, it's just called chromedriver) similarly shown below:

browser = webdriver.Chrome(executable_path=r"C:\path\to\chromedriver.exe")

(Set executable_path to the place(location) where your chromedriver is located.) 

If you've placed chromedriver on your System Path, you can shortcut by just doing the following: 

browser = webdriver.Chrome() 

       4, If you're running on a Unix-based operating system, you may need to update the permissions of chromedriver after downloading it in order to make it executable, using the following code snippet:

 chmod +x chromedriver

Welcome to Intellipaat Community. Get your technical queries answered by top developers !