运行时具体的错误提示:
DeprecationWarning: use options instead of chrome_options ? ? cls.driver = webdriver.Chrome(executable_path=driver_path,chrome_options=chrome_options)
**解决方案:
?将如下图的chrome_options参数改为options即可:
? 修改前:
![](https://img-blog.csdnimg.cn/20210712220711306.png)
? 修改后:
![](https://img-blog.csdnimg.cn/20210712220849211.png)
**原因:
?1、依据错误提示查看源码:
if chrome_options:
warnings.warn('use options instead of chrome_options', DeprecationWarning)
options = chrome_options
if options is None:
# desired_capabilities stays as passed in
if desired_capabilities is None:
desired_capabilities = self.create_options().to_capabilities()
else:
if desired_capabilities is None:
desired_capabilities = options.to_capabilities()
else:
desired_capabilities.update(options.to_capabilities())
? 2、根据源码的提示发现使用chrome_options 时会将chrome_options 值传给options,然后在给一个警告信息,根据错误信息已经源码的注解了解到未来options会取代chrome_options,所以我们只需要chrome_options改成options即可。
参考:https://www.cnblogs.com/mengyu/p/9706770.html
?
?
|