Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium not requiring ChromeDriver?

I made a simple Selenium script below in Python. This script runs perfectly for me, even though I don't specify the location of ChromeDriver (and as far as I can tell, I don't even have ChromeDriver installed). All other examples I've seen of simple Selenium programs require the user to specify the location of ChromeDriver.

Why does it not require ChromeDriver here?

from selenium import webdriver

website_url = 'https://microsoft.com'
driver = webdriver.Chrome()
driver.get(website_url)
driver.quit()
like image 557
Vux Avatar asked Sep 19 '25 20:09

Vux


1 Answers

As of selenium 4.10.0 the driver manager is fully integrated, and will silently download drivers as needed. (Eg. On Mac/Linux, drivers are automatically downloaded to the ~/.cache/selenium folder if not found on the PATH.) Slightly earlier versions of selenium had a beta of the driver manager.

Optionally now, if you want to specify a PATH, you can do so via the service arg:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path="PATH_TO_DRIVER")
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(service=service, options=options)
# ...
driver.quit()

But specifying the executable_path is optional now (and must be done via the service arg).

like image 189
Michael Mintz Avatar answered Sep 23 '25 12:09

Michael Mintz