Selenium 4.11.2中webdriver.Chrome()获取的ChromeDriver版本是多少?
关于Selenium 4.11.2中
webdriver.Chrome()获取ChromeDriver版本的说明 首先明确:webdriver.Chrome()不会自动获取最新版本的ChromeDriver,它的核心逻辑是匹配你本地已安装的Chrome浏览器版本。
从Selenium 4.6.0开始,官方引入了Selenium Manager工具,webdriver.Chrome()调用时会自动触发这个工具完成以下操作:
- 检测本地系统中已安装的Chrome浏览器的具体版本
- 根据浏览器版本,下载与之完全兼容的ChromeDriver版本(而非最新版驱动)
- 自动配置驱动路径,无需手动指定
举个例子:如果你的电脑上装的是Chrome 116.x版本,那么Selenium Manager会下载对应116.x系列的ChromeDriver,哪怕此时ChromeDriver已经更新到了117.x版本。
如果你的系统中没有安装Chrome浏览器,Selenium Manager会自动下载当前最新稳定版的Chrome浏览器,同时匹配对应的ChromeDriver版本——这是唯一会获取“最新”相关驱动的场景,但前提是无本地Chrome。
若你需要强制指定ChromeDriver版本,可以通过以下方式实现:
from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service options = Options() service = Service(executable_path="你指定的ChromeDriver路径") driver = webdriver.Chrome(service=service, options=options)
内容的提问来源于stack exchange,提问作者Super Kai - Kazuya Ito
相关产品推荐
相关产品推荐

