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
• 760 points
48,546 views
hey brother,

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

2 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())
answered Nov 27, 2018 by Srujan

selected Jan 10 by Kalgi

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")
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.

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,520 points
3,780 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,762 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,890 points
2,740 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 2 in Selenium by Sri
• 2,970 points
3,107 views
+10 votes
15 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
121,864 views
0 votes
1 answer