0

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()
Vux
  • 1

2 Answers2

1

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).

Michael Mintz
  • 9,007
  • 6
  • 31
  • 48
  • Was this `Selenium Manager` to handle browser drivers not already part of selenium since `Selenium v4.6.0`? What is new in `v4.10.0`? – Shawn Jun 15 '23 at 09:15
  • Selenium manager is fully integrated now. Lots of changes to args: https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e – Michael Mintz Jun 15 '23 at 10:57
0

No more mandatory.

Using Selenium v10.x and onwards you don't need to explicitly mention the ChromeDriver location through Service object or executable_path key.

The reason behind, incase ChromeDriver is not found as per your system's PATH settings it will automatically get downloaded using the new Selenium Driver Manager which is fully integrated within Selenium now.

  • Minimum code block:

    from selenium import webdriver
    
    driver = webdriver.Chrome()
    driver.get("https://www.google.com/")
    
  • Console Output:

    DevTools listening on ws://127.0.0.1:49197/devtools/browser/07e3d01a-32db-482a-a1e0-dc489efcc03c
    

tl; dr

References:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Was this `Selenium Manager` to handle browser drivers not already part of selenium since `Selenium v4.6.0`? What is new in `v4.10.0`? – Shawn Jun 15 '23 at 09:16