DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver =

代码:

option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
driver = Chrome(executable_path='chromedriver.exe', options=option)
driver.implicitly_wait(10)
driver.get('https://www.csdn.net/')

报错:

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

原因:

出现 DeprecationWarning 警告的类型错误:该类型的警告大多属于版本更新时,所使用的方法过时的原因,查询当前版本重构后的函数,是之前的 executable_path 被重构到了 Service 函数里

解决方案:

option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
service = Service('data/Application/chromedriver.exe')
driver = Chrome(service=service,options=option)
driver.implicitly_wait(10)
driver.get('https://www.csdn.net/')

你可能感兴趣的:(Python,chrome,python,前端)