python - selenium.common.exceptions.WebDriverException:消息:无效参数:无法识别的功能:带有 Selenium 和 ChromeDriver 77.0 的 chromeOptions
问题描述
这是我的代码
from selenium import webdriver
driver = webdriver.Chrome('C:\chromedriver_win32\chromedriver')
driver.get('http://google.com')
这是一条错误消息。
Traceback (most recent call last):
File "D:/project/Python/TEST_selenium/chromedriver_test.py", line 16, in <module>
driver = webdriver.Chrome(executable_path="C:\chromedriver_win32\chromedriver",chrome_options=chrome_options)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 98, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 188, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: unrecognized capability: chromeOptions
我无法弄清楚为什么这个简单的代码会出现错误。
此代码在一个月前有效。但它现在不起作用。
我已经更新了 chrome 和 chrome 驱动程序,但这并不能解决问题。
我的 chrome 和 chrome 驱动程序版本是 77。
解决方案
欢迎来到 SO!
根据您的问题,我猜您的硒版本已过时。我相信去 Chrome 驱动程序 77 更新了启动行为。
试试看pip install -U selenium
是否能解决您的问题。
推荐阅读
- angular - 当我有更多数据时,选择数据非常慢
- python - 如何编写测试代码以确保 __repr__ 的“返回”值?
- zk - 无法获取网格 zk java 中的行
- android - java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
- r - 如果满足其中一项要求,请更改列的值。不使用循环或 IF 语句
- jenkins - Jenkins/Groovy 将变量移出配置文件
- node.js - Cosmos DB 中的高效分页
- python - Scrapy spider 将 float / int 转换为字符串
- node.js - Node.js 服务器突然不工作了
- google-apps-script - 需要动态身份验证网址的 Gmail 插件问题