Error selenium common exceptions WebDriverException Message chromedriver executable needs to be in PATH

+1 vote

I get the following error:

Traceback (most recent call last):
  File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 992, 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:/Users/ishaq/AppData/Local/Programs/Python/Python36/headless.py", line 9, in <module>
    driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"),   chrome_options=chrome_options)
  File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Users\ishaq\AppData\Local\Programs\Python\Python36\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 https://sites.google.com/a/chromium.org/chromedriver/home

And my script is:

import os  
from selenium import webdriver  
from selenium.webdriver.common.keys import Keys  
from selenium.webdriver.chrome.options import Options 

chrome_options = Options()  
chrome_options.add_argument("--headless")  
chrome_options.binary_location = 
r'C:\Users\ishaq\Desktop\chrome\chromedriver.exe'    
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver"),   
chrome_options=chrome_options)  
driver.get("http://www.duo.com")

magnifying_glass = driver.find_element_by_id("js-open-icon")  
if magnifying_glass.is_displayed():  
  magnifying_glass.click()  
else:  
  menu_button = driver.find_element_by_css_selector(".menu-trigger.local")  
  menu_button.click() 

search_field = driver.find_element_by_id("site-search")  
search_field.clear()  
search_field.send_keys("Olabode")  
search_field.send_keys(Keys.RETURN)  
assert "Looking Back at Android Security in 2016" in driver.page_source
driver.close()
May 10, 2018 in Selenium by eLiJha
• 770 points
91,880 views
hey brother,

can i get ur mail ID so that we ccan discuss about the webdriver problems

4 answers to this question.

+4 votes
Best answer

You can also handle this error with python script:

In command line:

pip install webdriver-manager

Python script:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

Hope this helps!

Join our Selenium Certification training online and become the expert.

Thanks!

answered Nov 27, 2018 by Srujan

edited Aug 4, 2023 by Khan Sarfaraz

Hey @Dibya, have u tried srujan's solution?

Also refer to https://www.edureka.co/blog/selenium-using-python/

Hope this helps!

I am getting following with above code can anyone help here?

Traceback (most recent call last):
  File "chrome_code.py", line 2, in <module>
    from webdriver_manager.chrome import ChromeDriverManager
  File "/home/delhivery/Desktop/lambdatest/venv/lib/python3.5/site-packages/webdriver_manager/chrome.py", line 4, in <module>
    from webdriver_manager.driver import ChromeDriver
  File "/home/delhivery/Desktop/lambdatest/venv/lib/python3.5/site-packages/webdriver_manager/driver.py", line 77
    self.auth_header = {'Authorization': f'token {self._os_token}'}
                                                                 ^
SyntaxError: invalid syntax

Hello @ Akshat Garg,

Have  you tried to import the package called webdriver_manager? if not you can installed it by:

pip install webdriver_manager

Also this can be done automatically using webdriver-manager

Note:Our system needs to know where to locate the chromedriver.exe. You could put it into a directory that is in your system's PATH variable, or just tell the constructor where it is:

browser = webdriver.Chrome('C:\\path\\to\\chromedriver.exe')
THIS WORKED WONDERS!!!! THANK YOU
Hi, thank you for your contribution to the Edureka Community.

Register/Sign up on the community to gain points for further contributions. You may ask questions, answer, upvote, and downvote an answer. Each of these would fetch you points and you could be among the top contributors and win exciting merchandise from Edureka.

Cheers!
+1 vote

Very basic error. The main issue is with the path and driver execuable. So it's clear from the error that the Python client was unable to locate the chromedriver binary. When your mentioning the path of the driver, append it with the extension. Like this:

driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver.exe")
For details, You can even check out Selenium concepts with the Selenium online training.
answered May 10, 2018 by king_kenny
• 3,710 points
Thank you guys! The one with green tick worked for me :)
Hey, Please do upvote the answer in case you found it helpful.
0 votes

You can test if it actually is in the PATH, if you open a cmd and type in chromedriver (assuming your chromedriver executable is still named like this) and hit Enter. If Starting ChromeDriver 2.15.322448 is appearing, the PATH is set appropriately and there is something else going wrong.

Alternatively, you can use a direct path to the chromedriver like this:

 driver = webdriver.Chrome('/path/to/chromedriver') 

So in your specific case:

 driver = webdriver.Chrome("C:/Users/michael/Downloads/chromedriver_win32/chromedriver.exe"
answered Dec 14, 2020 by Roshni
• 10,480 points
0 votes

You can download ChromeDriver here: 

Then you have multiple options:

  • add it to your system path
  • put it in the same directory as your python script
  • specify the location directly via executable_path

    driver = webdriver.Chrome(executable_path='C:/path/to/chromedriver.exe')
answered Dec 14, 2020 by Gitika
• 65,770 points

Related Questions In Selenium

+1 vote
1 answer
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,731 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,171 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,247 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,887 views
+10 votes
17 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
198,164 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP