I'm writing a bunch of programs using python selenium. In order to scrape content from different websites, I need to download chromedriver.exe that is compatible with my current version of chrome. However, chrome is constantly being updated, so I want to write a program that will first check if chrome and chromedriver versions are compatible before running my programs. So, I need a way to get my current chrome version without using chromewebdriver or actually opening up a browser. Any suggestions?
4 Answers
For windows you could try with the CMD reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome" as follow:
import os
stream = os.popen('reg query "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"')
output = stream.read()
print(output)
To extract the google_version from the output you could try the following:
import os
def extract_version(output):
try:
google_version = ''
for letter in output[output.rindex('DisplayVersion REG_SZ') + 24:]:
if letter != '\n':
google_version += letter
else:
break
return(google_version.strip())
except TypeError:
return
stream = os.popen('reg query "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Google Chrome"')
output = stream.read()
google_version = extract_version(output)
print(google_version)

- 827
- 2
- 12
- 29
If you are working on Linux
:
Try this in terminal(If you want to get the result in python script, you need to use subprocess.popen()
):
google-chrome --version
You may need to use which google-chrome
to know whether you have install it.Hope it would help.

- 1,089
- 6
- 19
-
process = subprocess.Popen(["chromium-browser", "-version"], stdout=PIPE) output = process.communicate()[0] works for me. – modernxart Oct 10 '21 at 04:42
The new answer to this if you are using Selenium 4.6+ is you don't have to do anything. Selenium now ships with DriverManager that takes care of driver download/install/setup for you. All you need in your script is
driver = webdriver.Chrome()
driver.maximize_window()
driver.get(url)
No other setup, no paths to the binary needed, etc.

- 22,180
- 5
- 32
- 55
It's quite late but I have the solution for you. In Jupyter Notebook, you can do the following commands:
# install google chrome
!wget https://dl.google.com/linux/linux_signing_key.pub
!sudo apt-key add linux_signing_key.pub
!echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' >> /etc/apt/sources.list.d/google-chrome.list
!sudo apt-get -y update
!sudo apt-get install -y google-chrome-stable
# install chromedriver
# !apt-get install -y qq unzip
!wget -O /tmp/chromedriver.zip http://chromedriver.storage.googleapis.com/`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE`/chromedriver_linux64.zip
!unzip /tmp/chromedriver.zip chromedriver -d /usr/local/bin/
# To check Google Chrome's version
!google-chrome --version
# To check Chrome Driver's version
!chromedriver -v
# Scrap example
import time
from selenium import webdriver
# URL Stock Data
url = "<your url here>"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--window-size=1920,2160")
driver = webdriver.Chrome(options=chrome_options)
# head to login page
driver.get(url)
# find username field and send the username itself to the input field
driver.find_element("id", "userNameId").send_keys(mom_username)
# find password input field and insert password as well
driver.find_element("id", "passwordId").send_keys(mom_password)
# click login button
driver.find_element("id", "loginButtonId").click()
data = driver.page_source
data
time.sleep(10)

- 892
- 2
- 15
- 30