toshiro92 toshiro92 - 1 year ago 355
Python Question

Chrome webdriver cannot connect to the service chromedriver.exe on Windows

Hello !

I am currently using Selenium with Python on Windows 7, and I tried to use the Chrome webdriver for the hide function

. After I installed Chrome (x86), copied chromedriver.exe on path
and added it on PATH environment, I tried to launch it via the following code:

opt = Options()

driver = webdriver.Chrome(chrome_options=opt)

However, I have the following error when I execute it:

(env) c:\opt\project\auto\>python
Traceback (most recent call last):
File "", line 234, in <module>
File "", line 36, in main
File "c:\opt\project\auto\common\", line 32, in initChromeWebDriver
File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\chrome\webdriver.p
y", line 61, in __init__
File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\common\"
, line 88, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service chromedriver

Note: I am currently using a
also, so I also copied the chromedriver.exe on his
folder. Any idea about the issue here ?

Answer Source

first , instead of using Options() method you should use webdriver.ChromeOptions() method to have the result that you want, secondly you should specify the path to the Chromedriver installed on your computer.

for example put chormedriver.exe file on drive C:\ and use:

    chrome_options = webdriver.ChromeOptions()
    driver = webdriver.Chrome("C:\\chromedriver.exe", chrome_options=chrome_options)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download