You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:Selenium报错TypeError: WebDriver.__init__()收到意外参数chrome_options

解决ChromeOptions相关报错问题

你的代码报错是因为Selenium 4.x及以上版本已弃用chrome_options参数,需要改用options参数传递配置项。

修改后的代码如下:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
# 替换chrome_options为options参数
driver = webdriver.Chrome(options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe")
driver.get('http://google.com/')

额外注意事项:

  • 确保ChromeDriver版本与Chrome浏览器版本完全匹配,版本不兼容也会引发各类运行错误
  • 若使用Selenium 4.6+版本,无需手动指定executable_path,Selenium会自动管理驱动

内容的提问来源于stack exchange,提问作者Dibyajyoti Pattnaik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 11:28:13