ZBLOG

D:\pythonProjects\main.py:54: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome(path, options=options)

The warning message suggests that the executable_path argument used to specify the path to the Chrome driver executable is deprecated and a Service object should be passed instead.

Here’s an example of how to create a Service object and pass it to the Chrome webdriver:

  1. from selenium import webdriver
  2. from selenium.webdriver.chrome.service import Service
  3. # specify path to Chrome driver executable
  4. path = r"C:\path\to\chromedriver.exe"
  5. # create a Service object using the path
  6. service = Service(path)
  7. # specify options for Chrome webdriver
  8. options = webdriver.ChromeOptions()
  9. options.add_argument("--start-maximized")
  10. # create a Chrome webdriver instance with Service and options
  11. driver = webdriver.Chrome(service=service, options=options)

This should resolve the deprecation warning and allow you to use the latest version of Selenium.

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://golang.0voice.com/?id=4645

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?