Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic installation of the Chrome driver for the Chrome version

If the version of the chrome driver is different from the current chrome version, I want to write a python code that downloads and operates the chrome driver that matches the current chrome version.

This is all I've been looking for

driver = webdriver.Chrome(ChromeDriverManage().install(), chrome_options=chrome_options)

I think this code is inefficient because i have to install the chrome driver every time. Is there any way?

like image 737
kwsong0314 Avatar asked Oct 17 '25 03:10

kwsong0314


2 Answers

This is what the official docs says :

you can do

pip install chromedriver-autoinstaller

or

Import

import chromedriver_autoinstaller

Code :

from selenium import webdriver
import chromedriver_autoinstaller


chromedriver_autoinstaller.install()  # Check if the current version of chromedriver exists
                                      # and if it doesn't exist, download it automatically,
                                      # then add chromedriver to path

driver = webdriver.Chrome()
driver.get("http://www.python.org")
assert "Python" in driver.title

Reference : click here

like image 146
cruisepandey Avatar answered Oct 18 '25 16:10

cruisepandey


The chromedriver-autoinstaller library has worked well for me and uses a cache so it doesn't needlessly redownload the driver.

like image 40
Matthew Hamilton Avatar answered Oct 18 '25 16:10

Matthew Hamilton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!