0

Have looked for an answer, but couldn't find anything. It seems insistent on saying it can't find the file specified and then checks PATH, but can't see it even then :/ I've put the directory in PATH: http://imgur.com/a/ZP59w

Program:

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

Error:

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

If anyone could help that would be greatly appreciated.

4 Answers 4

2

I had the same problem and solved it by using Options method.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\Program Files (x86)\Google\Chrome Dev\Application\chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path=r"C:\Program Files (x86)\Google\chromedriver.exe", )
driver.get("https://www.google.com/")

Hope it solved your problem.

1

You could try passing it the path directly.

So I have the webdriver file on my dekstop so:

webdriver.Chrome('C:/Users/adam/Desktop/chromedriver.exe')

You can get the webdriver here.

0

You can use the following :

from selenium import webdriver

browser = webdriver.Chrome(r"*your path here*")

How to get path? If on windows system go to the extracted location of the webdriver press shift key and select Copy as Path

enter image description here

0
  1. Download the webdriver you want here: https://selenium-python.readthedocs.io/installation.html#drivers

  2. Unzip the folder you just downloaded, take the executable file (let's say chromedriver.exe) and put it somewhere (let's say in "C:\Users")

  3. Go back into your python code and change your line to :

driver = webdriver.Chrome(executable_path=r'C:\Users\chromedriver.exe')

It should work now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.