Search code examples
pythonpython-3.xselenium-webdriverselenium-chromedriver

Why do I need the ChromeDriver in Selenium?


I have following code:

from selenium import webdriver


driver = webdriver.Chrome()
driver.get("https://google.com")

This code works well except that it is really slow. I don´t use the ChromeDriver. Just the normal Chrome Browser on my Mac. Why do I have to download the ChromeDriver? It doesn´t speed up the code execution. I've already tried that.

Also: Why do I have to close the driver at the end of my programm with driver.close()? The browser closes automatically when the code is finished.

Thank you!


Solution

  • Your code is perfectly fine.

    selenium version > 4.12.0

    There is no need to download the chromedriver manually,

    Selenium's new in-built tool Selenium Manager will automatically download and manage the drivers for you.

    https://www.selenium.dev/documentation/selenium_manager/ https://www.selenium.dev/blog/2023/status_of_selenium_manager_in_october_2023/

    You do not have to use driver.close() with the above code.