Scripting >> Selenium >> Python >> How to avoid the need to automatically install the latest driver using webdriver_manager module

 

## The following examples are for Selenium 4.x

## Check installed version with

pip show selenium

## If not yet version 4.x, upgrade by

pip install selenium --upgrade



## Example for Chrome : selenium-webdriver-manager-chrome.py
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

browser = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
browser.get("https://www.google.com")
time.sleep(10)
browser.close()
browser.quit()


## Example for Firefox :
selenium-webdriver-manager-firefox.py
import time
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from webdriver_manager.firefox import GeckoDriverManager

browser = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))
browser.get("https://www.google.com")
time.sleep(10)
browser.close()
browser.quit()

webdriver_manager