My problem is chromedriver 78 (currently the latest) doesn't work with Chrome 77. Ubuntu still has 77 in the apt-get repo for google-chrome-stable. My regression script automatically pulls down the latest available chromedriver (unless you specifcally give it a version) which is currently 78. I want to add in some logic to my regression to check what version of Chrome is currently installed and automatically grab the appropriate chromedriver version. The regression has the ability to run on mac, linux or windows.

I have been trying to figure out how selenium (or the chromedriver) knows where the browser is installed. It seems to always just 'know'. Which would imply there is some way to automatically determine the location of the browser? If I had that, I would be able to call --version. But I can't for the life of me, figure out how to determine where chrome is installed (programmatically, anyway).

Is there a way to programmatically determine what the chrome version is for a given OS?


3 Answers 3


It turns out the reason chromedriver knows where chrome is installed is it looks for it in the default installation locations. See chromedriver requirements enter image description here

I ended up using writing this script.

def chrome_version():
    osname = platform.system()
    if osname == 'Darwin':
        installpath = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
    elif osname == 'Windows':
        installpath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
    elif osname == 'Linux':
        installpath = "/usr/bin/google-chrome"
        raise NotImplemented(f"Unknown OS '{osname}'")

    verstr = os.popen(f"{installpath} --version").read().strip('Google Chrome ').strip()
    return verstr

note: it appears the chromedriver documentation is a little out of date with the windows install location


You can obtain the browser version via WebDriver like this:

    Capabilities cap = ((ChromeDriver) driver).getCapabilities();

I have tested it on Windows using old WebDriver version (2.44) vs current Chrome (78), I am not sure how this will work with new WebDriver vs old chrome on Ubuntu.

  • Unfortunately this requires the chromedriver to work. I'm trying to work around the case where chromedriver is incompatible with the version of chrome installed. Commented Oct 31, 2019 at 14:22

Why dont you use the chromedriver from the repo? Should be the same version, when OS == Linux don't run your get latest chromedriver script. I think this is much simpler than detecting the Chrome version, which would be different code for each OS.

The command --version should work if you hard code the location for each OS, detect the OS instead.

  • I'm not sure if I understand. Which repo? The chromedriver repo? Commented Oct 31, 2019 at 14:23
  • @MarcelWilson The apt-get repository also has a package called chrome-driver, but i guess that doesnt work with chrome-stable package but with the Ubuntu Chromium version. Commented Oct 31, 2019 at 14:46
  • Ahh, yeah. There is no guarantee the chromedriver version will be in sync with chrome in the apt-get repo. Commented Oct 31, 2019 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.