Chrome webdriver cannot connect to the service chromedriver.exe on Windows
<p>Hello !</p>

<p>I am currently using Selenium with Python on Windows 7, and I tried to use the Chrome webdriver for the hide function <code>--no-startup-window</code>. After I installed Chrome (x86), copied chromedriver.exe on path <code>C:\Python27\Scripts\</code> and added it on PATH environment, I tried to launch it via the following code:</p>

<pre><code>opt = Options()
opt.add_argument("--no-startup-window")

driver = webdriver.Chrome(chrome_options=opt)
</code></pre>

<p>However, I have the following error when I execute it:</p>

<pre><code>(env) c:\opt\project\auto\&gt;python program_test.py
Traceback (most recent call last):
  File "program_test.py", line 234, in &lt;module&gt;
    main()
  File "program_test.py", line 36, in main
    initChromeWebDriver()
  File "c:\opt\project\auto\common\driver.py", line 32, in initChromeWebDriver
    service_log_path=)
  File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\chrome\webdriver.p
y", line 61, in __init__
    self.service.start()
  File "c:\opt\project\auto\lib\site-packages\selenium\webdriver\common\service.py"
, 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
</code></pre>

<p>Note: I am currently using a <code>virtualenv</code> also, so I also copied the chromedriver.exe on his <code>Scripts</code> folder. Any idea about the issue here ?</p>

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

<p>for example put chormedriver.exe file on drive C:\ and use:</p>

<pre><code>    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--no-startup-window")
    driver = webdriver.Chrome("C:\\chromedriver.exe", chrome_options=chrome_options)

    driver.get("www.google.com")
</code></pre>

python google-chrome selenium selenium-webdriver webdriver