close

[Solved] DeprecationWarning: executable_path has been deprecated, please pass in a Service object

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to open chrome webdriver with selenium But I am facing following error DeprecationWarning: executable_path has been deprecated, please pass in a Service object in Python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How DeprecationWarning: executable_path has been deprecated, please pass in a Service object Error Occurs ?

I am trying to open chrome webdriver with selenium But I am facing following error.

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

How To Solve DeprecationWarning: executable_path has been deprecated, please pass in a Service object Error ?

  1. How To Solve DeprecationWarning: executable_path has been deprecated, please pass in a Service object Error ?

    To Solve DeprecationWarning: executable_path has been deprecated, please pass in a Service object Error Here executable_path is deprecated you have to use an instance of the Service() class as follows. s = Service('C:/Users/…/chromedriver.exe') and then driver = webdriver.Chrome(service=s) Now, Your error must be solved.

  2. DeprecationWarning: executable_path has been deprecated, please pass in a Service object

    To Solve DeprecationWarning: executable_path has been deprecated, please pass in a Service object Error Here executable_path is deprecated you have to use an instance of the Service() class as follows. s = Service('C:/Users/…/chromedriver.exe') and then driver = webdriver.Chrome(service=s) Now, Your error must be solved.

Solution 1: Just use an instance of the Service()

Here executable_path is deprecated you have to use an instance of the Service() class as follows.

from selenium import webdriver

PATH = './chromedriver.exe'
driver = webdriver.Chrome(PATH)
driver.get("https://www.google.com")

This will Give You deprecated warning So You Have to use an instance of the Service() class instead of executable_path just like This.

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

s = Service('C:/Users/.../chromedriver.exe')
driver = webdriver.Chrome(service=s)

Now, Your error must be solved.

Solution 2: Use this code

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
ser = Service("C:\\chromedriver.exe")
op = webdriver.ChromeOptions()
s = webdriver.Chrome(service=ser, options=op)

Solution 3: Before and after

Before

from selenium import webdriver
chrome_driver_path = 'C:/Users/ssc/ChromeDriver/chromedriver.exe'
driver = webdriver.Chrome(executable_path=chrome_driver_path)

url = "https://www.google.com"
driver.get(url)

After

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

s=Service('C:/Users/ssc/ChromeDriver/chromedriver.exe')
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

4 thoughts on “[Solved] DeprecationWarning: executable_path has been deprecated, please pass in a Service object”

  1. Thank you for such a clear explanation. My code was still running but I wanted to solve the deprecation error and had spent a lot of time doing so.

    Very Grateful!

    Reply

Leave a Comment