What is default location of ChromeDriver and for installing Chrome on Windows
Asked Answered
G

7

31

I need to install chromedriver on Windows OS. In the article below they specify:

https://sites.google.com/a/chromium.org/chromedriver/getting-started

"...ChromeDriver expects you to have Chrome installed in the default location for your platform..."

But I'm not sure what is the default location ?

On Mac OS it's /usr/local/bin.

With this I don't have to specify path explicitly or setup system path either.

How to achieve the same on Windows OS?

Giltzow answered 12/4, 2018 at 4:54 Comment(0)
G
4

For any driver that Selenium must use to open the browser (chromedriver, geckodriver, etc), you don't have to worry about where it is installed, as long as it's set in the PATH variable.

If you have it set in the OS PATH variable, you must be able to run it from the command or cmd (it's always good to make sure it's working).

Here's how you can set it (append to the existing value):

Then you can just instantiate it as follows:

WebDriver driver = new FirefoxDriver();

OR

WebDriver driver = new ChromeDriver();

Hope it's somehow helpful.

Gwenn answered 12/4, 2018 at 11:31 Comment(3)
Thanks to your youtube video link, I figured out that I need to put chromedriver under c:\program files\any_folder. But this path I need to mention under PATH, still it didn't solve my query why can't Windows know about chromedriver put under c:\program files , why I need to explicitly mention that path under PATH ? With Mac/ Ubuntu if I just put under /user/local/bin, chromedriver works fineGiltzow
On Mac/Ubuntu it works fine, because /usr/local/bin is in the PATH (usr is a short to User System Resources, not user). To check that, open a terminal in a Linux/Mac and type env | grep PATH to check it is there. So, in Linux/Mac, when you install/copy to /usr/local/bin, you're already installing in a folder seen by the PATH variable. I'm not sure the command env works on Windows, but you can still run echo %PATH% to show all the directories listed by it.Gwenn
This solution is no longer valid. Even if chromedriver.exe is on the path, you will get this error: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from chromedriver.storage.googleapis.com/index.htmlRiordan
D
29

These are two interrelated important questions as follows :

  • Default location of ChromeDriver
  • Default location of Chromium/Google Chrome

ChromeDriver

You can download the recently released ChromeDriver from ChromeDriver - WebDriver for Chrome page and place it any where within your system. When you initialize the ChromeDriver you need to pass the absolute path of the ChromeDriver binary.

Additionally, you can also help WebDriver to locate the downloaded ChromeDriver executable through the following steps :

  • Include the ChromeDriver location in your system PATH environment variable.
  • (Java) Specify the location of ChromeDriver through the webdriver.chrome.driver system property
  • (Python) Specify the location of ChromeDriver when instantiating webdriver.Chrome()

Chromium/Google Chrome

The most important fact is you need to ensure that Chromium/Google Chrome is installed in a recognized location as per the ChromeDriver - Requirements as the server expects you to have Chromium/Google Chrome installed in the default location for each system as per the snapshot:

ChromeDriver - Requirements

Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following Using a Chrome executable in a non-standard location .

Sample Code Block

  • Java :

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    public class A_Chrome 
    {
        public static void main(String[] args) 
        {
            // Optional : if not specified WebDriver will search your system PATH environment variable for locating the chromedriver
            System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
            WebDriver driver =  new ChromeDriver();
            driver.get("https://www.google.co.in");
            System.out.println(driver.getTitle());
            driver.quit();
        }
    }
    
  • Python :

    from selenium import webdriver
    
    # Optional argument : if not specified WebDriver will search your system PATH environment variable for locating the chromedriver
    driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
    driver.get('https://www.google.co.in')
    print("Page Title is : %s" %driver.title)
    driver.quit()
    
Doody answered 12/4, 2018 at 11:27 Comment(1)
Can you please take a look at this question: #77395999Riccio
G
4

For any driver that Selenium must use to open the browser (chromedriver, geckodriver, etc), you don't have to worry about where it is installed, as long as it's set in the PATH variable.

If you have it set in the OS PATH variable, you must be able to run it from the command or cmd (it's always good to make sure it's working).

Here's how you can set it (append to the existing value):

Then you can just instantiate it as follows:

WebDriver driver = new FirefoxDriver();

OR

WebDriver driver = new ChromeDriver();

Hope it's somehow helpful.

Gwenn answered 12/4, 2018 at 11:31 Comment(3)
Thanks to your youtube video link, I figured out that I need to put chromedriver under c:\program files\any_folder. But this path I need to mention under PATH, still it didn't solve my query why can't Windows know about chromedriver put under c:\program files , why I need to explicitly mention that path under PATH ? With Mac/ Ubuntu if I just put under /user/local/bin, chromedriver works fineGiltzow
On Mac/Ubuntu it works fine, because /usr/local/bin is in the PATH (usr is a short to User System Resources, not user). To check that, open a terminal in a Linux/Mac and type env | grep PATH to check it is there. So, in Linux/Mac, when you install/copy to /usr/local/bin, you're already installing in a folder seen by the PATH variable. I'm not sure the command env works on Windows, but you can still run echo %PATH% to show all the directories listed by it.Gwenn
This solution is no longer valid. Even if chromedriver.exe is on the path, you will get this error: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from chromedriver.storage.googleapis.com/index.htmlRiordan
R
2

Default location on Windows is: C:\Program Files\(select the folder you want to put your file)\chromedriver.exe

In your Selenium code, paste the driver path correctly, for example:

System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");
Reverso answered 12/4, 2018 at 5:7 Comment(4)
If I don't want to hard code that path value in program, is there any alternative ? In Mac OS, if I don't have to do all these workaround as it knows default locationGiltzow
Try pasting the "chromedriver.exe" file inside the selenium file (selenium installation files) . Hope it worksReverso
I' m not sure what do u mean by default location for installing. Anyhow it is not installing it';s just u r downloading and keeping a copy of file. If you dont want to hard code the location keep the chromedriver.exe file in prj root dir and use System.getProperty("user.dir") and append chromedriver.exe to make it relative pathPatin
Thanks, I figured out that I need to put chromedriver under c:\program files\any_folder. But this path I need to mention under PATH, still it didn't solve my query why can't Windows know about chromedriver put under c:\program files , why I need to explicitly mention that path under PATH ? With Mac/ Ubuntu if I just put under /user/local/bin, chromedriver works fineGiltzow
H
1

If you are using a Python virtual environment with 'virtualenv'. You can drop the chromedriver.exe in your virtual environment's bin/ directory.

> virtual venv
> cd Users/username/Downloads/chromedriver(.exe) working/directory/path/venv/bin/

Then try running the Python script with the virtual env's interpreter.

Handrail answered 17/1, 2020 at 2:16 Comment(0)
F
1

Download the standalone package and link to it.

I have found that to download the package to your desktop and to point to it in your program is just the simplest and easiest solution

I found a link for the standalone package here.

You can then point to the package with a little bit of code like the following.

from selenium import webdriver
from bs4 import BeautifulSoup
import time
import pandas as pd


driver = webdriver.Chrome("The-Path-To-The-Web-Driver")
Fatwitted answered 28/3, 2023 at 10:44 Comment(0)
G
0

My chromedriver package was installed in my Python folder. If I remember correctly, I installed it with pip. The strange thing is that the chromedriver folder did not contain the chromedriver.exe file, which I had to download and move to the site-packages folder separately.

C:\\Users\\_USERNAME_\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\site-packages\\chromedriver

(I use double \:s in the path because a single \ plus the letter U (in C:-->\U<--sers...) would result in

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

)

Gastritis answered 10/1, 2020 at 9:53 Comment(0)
E
0

Interestingly i didnt find a single entry pointing me to the right direction for me, however, checking my installation via which chromedriver revealed that my correct location was:

/opt/homebrew/bin/chromedriver

I stumbled upon this because i first tried downloading the binary which was version 114 and then installed via brew version 126 which presented a mismatch. To me installing via proved more stable.

Eyecup answered 22/7, 2024 at 16:54 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.