webdriver-manager
webdriver-manager is a Python library that automatically manages browser drivers for Selenium. It handles downloading, installing, and caching the correct driver executable for your installed browser, eliminating manual driver management. The current version is 4.0.2, and it maintains an active release cadence with frequent bug fixes and support for new browser versions.
Warnings
- breaking Version 4.0.0 introduced significant internal refactoring of driver classes. While the primary `.install()` method generally remained stable, custom or advanced integrations with internal driver manager components may require updates.
- gotcha Prior to v4.0.0, the library could raise unhandled `NameError` or `TypeError` exceptions if running offline or if it failed to detect the installed browser's version, leading to script failures.
- gotcha Users working with Chrome browser versions less than 113 might encounter issues with driver downloads due to changes in Chrome's driver distribution method. This was specifically addressed in `webdriver-manager` v4.0.1.
- gotcha Chromedriver download URLs for Apple M1/M2 (ARM) Macs changed, causing download failures for users on this architecture with `webdriver-manager` versions prior to v3.8.4.
Install
-
pip install webdriver-manager
Imports
- ChromeDriverManager
from webdriver_manager.chrome import ChromeDriverManager
- GeckoDriverManager
from webdriver_manager.firefox import GeckoDriverManager
- EdgeChromiumDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager
- OperaDriverManager
from webdriver_manager.opera import OperaDriverManager
Quickstart
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# Automatically download and install the correct ChromeDriver
driver_path = ChromeDriverManager().install()
# Initialize the Chrome service with the installed driver
service = Service(driver_path)
# Initialize the Chrome WebDriver
driver = webdriver.Chrome(service=service)
# Example usage: navigate to a page
driver.get("https://www.google.com")
print(f"Page title: {driver.title}")
# Close the browser
driver.quit()