英文:
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可以自行处理。
请参考以下代码比较:
- 在不使用
WebDriverManager
并手动设置driver.exe
路径的情况下:
driver = webdriver.Chrome('C:\\Users\\xxx\\Downloads\\chromedriver_win32\\chromedriver.exe')
driver.get("http://www.seleniumhq.org/")
- 使用
WebDriverManager
:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("http://www.seleniumhq.org/")
- 使用最新的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:
- Without using
WebDriverManager
and setting thedriver.exe
path manually:
driver = webdriver.Chrome('C:\\Users\\xxx\\Downloads\\chromedriver_win32\\chromedriver.exe')
driver.get("http://www.seleniumhq.org/")
- Using
WebDriverManager
:
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("http://www.seleniumhq.org/")
- Using latest selenium(
v4.6.0
or above):
driver = webdriver.Chrome()
driver.get("http://www.seleniumhq.org/")
References:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论