26

We have an Ubuntu server which we use for running Selenium tests with Chrome and Firefox (I installed ChromeDriver) and I also want to run the tests locally on my Windows 10 computer. I want to keep the Python code the same for both computers. But I didn't find out how to install the ChromeDriver on Windows 10? I didn't find it on the documentation [1, 2].

Here is the code that runs the test in Chrome:

import unittest
from selenium import webdriver

class BaseSeleniumTestCase(unittest.TestCase):
    ...
    ...
    ...
    ...

    def start_selenium_webdriver(self, chrome_options=None):
        ...
        self.driver = webdriver.Chrome(chrome_options=chrome_options)
        ...

I also found How to run Selenium WebDriver test cases in Chrome? but it seems to be not in Python (no programming language is tagged, what is it?)

Update #1: I found some Python code in https://sites.google.com/a/chromium.org/chromedriver/getting-started, but where do I put the file in Windows 10 if I want to keep the same Python code for both computers?

Update #2: I downloaded and put chromedriver.exe in C:\Windows and it works, but I didn't see it documented anywhere.

Community
  • 1
  • 1
Uri
  • 2,992
  • 8
  • 43
  • 86
  • 1
    Is this still working for you after the latest Chrome updates? My test browser now comes up empty next to a small Command Prompt window. – Alex R Oct 27 '15 at 12:25
  • 1
    @AlexR Yes, it works. – Uri Oct 28 '15 at 11:17
  • 1
    This site really helped me https://jonathansoma.com/lede/foundations-2018/classes/selenium/selenium-windows-install/ – ikmazameti Aug 18 '22 at 11:50

3 Answers3

25

As Uri stated in the question, under Update #2, downloading the latest release of chromedriver and placing it in C:\Windows corrects the issue.

I had the same issue with Chrome hanging when the browser window opens (alongside a command prompt window).

The latest drivers can be found at:

https://sites.google.com/chromium.org/driver

The version in the chromedriver_win32.zip file is working on my 64-bit system.

Adam Starrh
  • 6,428
  • 8
  • 50
  • 89
7
  1. Download the chromedriver.exe and save it to a desired location
  2. Specify the executable_path to its saved path

The sample code is below:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('headless')
driver = webdriver.Chrome(executable_path="path/to/chromedriver.exe", chrome_options=options)
driver.get("example.html")
# do something here...
driver.close()

As Uri stated in Update #2 of the question, if we put the chromedriver.exe under C:/Windows, then there is no need to specify executable_path since Python will search under C:/Windows.

Gaoping
  • 251
  • 3
  • 5
5

Let me brief out the requirements first. You need to download the chrome web driver zip from here. https://chromedriver.storage.googleapis.com/index.html?path=2.33/

Extract the file and store it in a desired location.

Create a new project in Eclipse and include the following code in your class.

System.setProperty("webdriver.chrome.driver", "C:\\temp\\chromedriver.exe");
WebDriver driver = new ChromeDriver();

Explanation : System.setProperty(key,value):

Key is default and same for all the systems, value is the location of your chromedriver extract file.

Thomas Rollet
  • 1,573
  • 4
  • 19
  • 33