2

I have tried to get selenium chrome driver working for weeks but I run into the same problem, selenium can't find my chromedriver.exe file

I am currently on Windows 10 and my version on chrome is 76.0.3809.100. I pip installed selenium in a virtual environment that is located in an EXTERNAL HARD DRIVE (E:). I try the basic chrome driver setup by calling

from selenium import webdriver
browser = webdriver.Chrome()

I put chromedriver.exe in my path, and I can verify that by typing chromedriver in cmd and I get this output. It seems like it is the same version of chrome that I am using

Starting ChromeDriver 76.0.3809.126 (d80a294506b4c9d18015e755cee48f953ddc3f2f-refs/branch-heads/3809@{#1024}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

The error that I get when I try to run this test program is this.

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

I have tried different combinations of putting chromedriver.exe in various folders (using forward slashes and double backslashes) and running

from selenium import webdriver
browser = webdriver.Chrome("C:/python/Scripts/chromedriver.exe")

from selenium import webdriver
browser = webdriver.Chrome(r"C:/python/Scripts/chromedriver.exe")

from selenium import webdriver
browser = webdriver.Chrome(executable_path="C:/python/Scripts/chromedriver.exe")


from selenium import webdriver
browser = webdriver.Chrome("E:\\SportsReference\\seleniumc\\chromedriver.exe")

from selenium import webdriver
browser = webdriver.Chrome(r"E:\\SportsReference\\selenium\\chromedriver.exe")

from selenium import webdriver
browser = webdriver.Chrome(executable_path="E:\\SportsReference\\selenium\\chromedriver.exe")


etc.....

Every time I try to run one of the test programs above, I get the same error saying chromedriver needs to be in my path.

Someone, please help me because I have spent so much time just trying to get this basic test up and running.

ChaseRun
  • 21
  • 1
  • 7

2 Answers2

0

You can refer following implementation :

driverlocation = "C:\\Python37\\Chromedriver.exe"
os.environ["webdriver.Chrome.driver.driver"] =driverlocation
driver = webdriver.Chrome(driverlocation)
Rohit Gawas
  • 267
  • 3
  • 8
  • This doesn't work for me. I get the same error – ChaseRun Aug 24 '19 at 19:00
  • @ChaseRun kindly check your chromedriver version is compatible with your chrome browser version or not. You can refer following link to check the compatability : https://chromedriver.chromium.org/downloads – Rohit Gawas Aug 25 '19 at 13:40
0

I think you need to copy your chormedriver.exe file into your python file directory means for example if you save your python file in desktop then paste your chromedriver into desktop type this in your code:

from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('Your_url')
Hamza Lachi
  • 1,046
  • 7
  • 25
  • This doesn't seel to work. I tired putting Chromedriver.exe in my C:\Windows folder and my C:\python folder and I get the same error – ChaseRun Aug 24 '19 at 18:59
  • You need to put your chrome driver in you file directory for example if you save in desktop then paste chrome driver here so you need to paste your where your file save and then try my code – Hamza Lachi Aug 25 '19 at 02:58
  • put it in a directory that is specified in the system PATH – Corey Goldberg Aug 26 '19 at 02:40