Automatically Updating WebDriver matching with browser using python

Yubaraj Singh
2 min readMar 9, 2022

I had built a web application that need web automation. So I used python Selenium for web automation. The application software was running smoothly and it has only one problem that occurs when my browser(chrome) update automatically and the software stops working. So to keep running, I frequently download the matching version of webdriver and replace the old webdriver. So to automatically download the new webdriver of chrome here are the steps to follow:

  • import required package
  • get Chrome browser version and chrome webdriver version
  • Then we need to check if the chrome version is matching or not and apply if-else condition

so hereafter I checked the version and using if condition the version isn’t matching then I close the running webdriver and quit the webdriver.
Afterwards, using request.get to get the latest version of chrome webdriver.
Then using wget , I download the zip file.

lastly, unpack the zip file using zip_ref and remove the zip file.
Now we are good to go with if the version isn’t matching condition. If the version are matching then our web automation will run smoothly without any trouble and there is no need to update the webdriver manually.

So in this way I was able to automatically download the matching version of chrome webdriver.

Reference:

Automatic download of appropriate chromedriver for Selenium in Python — Stack Overflow

--

--

Yubaraj Singh

I am Tech enthusiast, movie lover and admirer of Art and Innovations.