Categories
Automated testing Python Selenium WebDriver

Now you don’t need to install chromedriver

In the past, before you could start using Selenium, you had to install drivers to interact with browsers. In order to be able to give commands to the browser, you had to install chromedriver or edgedriver or geckodriver, depending on which browser you intended to test on. Otherwise, you received an error with the text like this:

The path to the driver executable must be set by the webdriver.chrome.driver
system property; for more information, see https://chromedriver.chromium.org/. The latest version can be
downloaded from https://chromedriver.chromium.org/downloads

I told about installing drivers using chromedriver as an example in this post about Selenium initial configuration.

Installing Selenium for the first time

If you are a new user of Selenium, you won’t even know that anything else other than pip install selenium was once required. Also, if you are installing Selenium on a new computer that has never had selenium drivers, you won’t have to do any extra steps either.

Now, Selenium itself takes care of installing the necessary drivers and keeping them up to date. This became possible due to the fact that the Selenium Manager was developed for Selenium, which is now a built-in selenium component starting from version 4.6.0.

Selenium Manager activation

If you have already used Selenium and upgraded to a version containing Selenium Manager (> 4.5.0), then you will have to take additional steps in order for Selenium to start managing drivers on its own.

Selenium Manager is activated only if during the installation of selenium version > 4.5.0 there are no browser drivers installed on your computer. More precisely, Selenium checks if there are drivers for browsers in any of the folders located in the PATH system variable.

So, in order to activate this functionality, you need to follow 3 steps:

  • Remove browser drivers from your computer. At the very least, you need to remove them from the folders located in the Path system variable.
  • Remove selenium module with command
    pip uninstall selenium
  • Install selenium again with the command
    pip install selenium

Most likely everything will work without uninstalling Selenium, but with a simple upgrade. The reinstall option is usually more stable for large changes.

As a result, you can forget about checking the relevance of drivers yourself. Selenium Manager will take care of this for you.

By Eugene Okulik