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:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
# specify path to Chrome driver executable
path = r"C:\path\to\chromedriver.exe"
# create a Service object using the path
service = Service(path)
# specify options for Chrome webdriver
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
# create a Chrome webdriver instance with Service and options
driver = webdriver.Chrome(service=service, options=options)
This should resolve the deprecation warning and allow you to use the latest version of Selenium.