webdriver manager的目的是管理Web驱动程序。

huangapple go评论58阅读模式
英文:

Purpose of webdriver manager

问题

如果我们将webdriver manager导入到我们的Selenium代码中(从webdriver_manager.chrome导入ChromeDriverManager),那么我们就不需要保持更新浏览器驱动程序,比如chromedriver、geckodriver等等。它会自动升级吗?

英文:

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?

答案1

得分: 0

当我们使用webdriver_manager时,它会自动帮助管理浏览器驱动程序,消除了手动更新的需求。

webdriver_manager库,比如你提到的ChromeDriverManager,提供了一种方便的方式来安装和管理浏览器驱动程序。它会下载适用于指定浏览器版本和操作系统的驱动程序可执行文件。

使用webdriver_manager的优点在于它可以自动检查浏览器驱动程序的最新版本,并在需要时下载相应版本。这确保了您的代码与最新的浏览器和驱动程序版本兼容,无需手动干预。

在您的代码中使用webdriver_manager简化了浏览器驱动程序管理的过程,并确保了您的代码与正在使用的浏览器兼容。

英文:

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.

答案2

得分: 0

以下是翻译好的部分:

尽管问题具体涉及到WebDriverManager的使用,但我想强调一下Selenium的新特性。从Selenium版本v4.6.0开始,Selenium内置了一个名为SeleniumManager的功能,本质上与WebDriverManager相似,如果不相同的话。

换句话说,如果您使用的是Selenium版本v4.6.0或更高版本,您不需要第三方库(webdrivermanager)来处理驱动程序和浏览器。Selenium可以自行处理。

请参考以下代码比较:

  1. 在不使用WebDriverManager并手动设置driver.exe路径的情况下:
driver = webdriver.Chrome('C:\\Users\\xxx\\Downloads\\chromedriver_win32\\chromedriver.exe')
driver.get("http://www.seleniumhq.org/")
  1. 使用WebDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("http://www.seleniumhq.org/")
  1. 使用最新的Selenium(v4.6.0或更高版本):
driver = webdriver.Chrome()
driver.get("http://www.seleniumhq.org/")

参考资料:

英文:

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:

huangapple
  • 本文由 发表于 2023年6月12日 14:13:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76453996.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定