Purpose of webdriver manager
Asked Answered
C

2

1

If webdriver manager is imported into our selenium code (from webdriver_manager.chrome import ChromeDriverManager), then it is not required that we need to keep updating the browser drivers like chromedriver,geckodriver,... will it keep upgrading itself?

Carriole answered 12/6, 2023 at 6:13 Comment(0)
S
0

Yes, when we use webdriver_manager, it helps manage the browser drivers automatically, eliminating the need for manual updates.

The webdriver_manager library, such as ChromeDriverManager as you mentioned, provides a convenient way to install and manage browser drivers. It downloads the appropriate driver executable for the specified browser version and operating system.

The advantage of using webdriver_manager is that it can automatically check the latest version of the browser driver and download the corresponding version if needed. This ensures that your code works with the latest browser and driver versions without requiring manual intervention.

Using webdriver_manager in your code simplifies the process of managing browser drivers and ensures compatibility between your code and the browser being used.

Souvaine answered 12/6, 2023 at 6:25 Comment(2)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) Sir,can u explain this part?Carriole
Even if you have already installed the webdriver_manager package using pip, including this statement in your code is necessary to ensure that the correct version of the ChromeDriver is downloaded and installed at runtime.Souvaine
E
0

Although the question is specific to the use of WebDriverManager, would like to highlight about selenium's new feature. Starting from selenium v4.6.0 and onwards, selenium has an in-built feature known as SeleniumManager, which essentially is similar to if not same as WebDrivermanager.

In other words, if you are using selenium v4.6.0 or above, you don't need a third party library(webdrivermanager) to handle your driver and browsers. Selenium can do it by itself.

Refer the code comparison below:

  1. Without using WebDriverManager and setting the driver.exe path manually:
driver = webdriver.Chrome('C:\\Users\\xxx\\Downloads\\chromedriver_win32\\chromedriver.exe')
driver.get("http://www.seleniumhq.org/")
  1. Using WebDriverManager:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("http://www.seleniumhq.org/")
  1. Using latest selenium(v4.6.0 or above):
driver = webdriver.Chrome()
driver.get("http://www.seleniumhq.org/")

References:

Excellence answered 12/6, 2023 at 10:1 Comment(2)
So In the latest version of selenium, it keeps checking for the updates automatically and downloads without human intervention ,I have selenium 4.9,so it enough to have this line of code alone,driver = webdriver.Chrome()Carriole
Yes, that's correct.Excellence

© 2022 - 2024 — McMap. All rights reserved.