selenium 报错 DeprecationWarning: executable

selenium 报错 DeprecationWarning: executable,第1张

DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path='chromedriver.exe')

出现 DeprecationWarning 警告的类型错误:该类型的警告大多属于版本已经更新,所使用的方法过时。


查询当前版本重构后的函数,是之前的 executable_path 被重构到了 Service 函数里

尝试解决方法:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

# 尝试传参
s = Service("chromedriver.exe")
driver = webdriver.Chrome(service=s)


driver.get('https://www.baidu.com/')
driver.quit() 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/564383.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-06
下一篇 2022-04-06

发表评论

登录后才能评论

评论列表(0条)

保存