Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install ChromeDriver on Windows 10 and run Selenium tests with Chrome?

Tags:

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.

like image 501
Uri Avatar asked Oct 15 '15 13:10

Uri


People also ask

Do we need to install ChromeDriver for Selenium?

As Google Chrome dominates the browser market, the use of a ChromeDriver becomes a must. Selenium WebDriver uses the ChromeDriver to communicate test scripts with Google Chrome.

Does ChromeDriver need Chrome installed?

ChromeDriver expects you to have Chrome installed in the default location for your platform. You can also force ChromeDriver to use a custom location by setting a special capability.

Where should I put ChromeDriver for Selenium?

Now we need to move ChromeDriver somewhere that Python and Selenium will be able to find it (a.k.a. in your PATH ). The easiest place to put it is in C:\Windows .


1 Answers

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/a/chromium.org/chromedriver/downloads

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

like image 170
Adam Starrh Avatar answered Dec 31 '22 13:12

Adam Starrh