How to get the ChromeDriver automatically updated through Python selenium after compiling using Pyinstaller

Viewed 8528

I use to pack the Chromedriver into my exe package too but as people say it changes quite frequently.

So I try the auto check for update method using the selenium import webdriver which also worked like a dream in the IDE however when I compile the code to exe file using Pyinstaller method it then falls and will no longer download the update to my temp MEIPASS location where I later execute the driver for the remainin part of my program.
Could this be windows some how blocking this type of request now it is within an exe file?

Just as an update here it is probably because I am unsure where the autoupdater extracts the new chromedrive to does anybody know where the driver will be placed when it updates?

2 Answers

There is a python pakage called chromedriver-autoinstaller. It can be used to auto-update chromedriver You can install it by using pip install chromedriver-autoinstaller command.

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

webdriver-auto-update

There is a package in PyPI and GitHub called webdriver-auto-update, that you could use for a simple and effective way to download chrome driver automatically.

Program Functionality

  1. Detects local chromedriver driver version on your computer and compares it with the latest version available online.
  2. The latest online version/release will be downloaded automatically if it does not match your local version.

Installation: Make sure you have Python installed in your system. Run the following in your terminal to install: pip install webdriver-auto-update

Example

from selenium import webdriver
from webdriver_auto_update import check_driver


# Pass in the folder used for storing/downloading chromedriver
check_driver('folder/path/of/your/chromedriver')

driver = webdriver.Chrome()
driver.get("http://www.python.org")

Reference link:

https://pypi.org/project/webdriver-auto-update/ https://github.com/competencytestlvl/webdriver_auto_update

Related