Deprecationwarning: executable_path Has Been Deprecated [Solved]

The Deprecationwarning: executable_path has been deprecated is an error warning that arises when the executable_path argument is used in the selenium version 4.0, as this version does not accept the executable_path argument. This article here will give you a walkthrough regarding the Deprecationwarning: executable_path has been deprecated error warning and ways to resolve these.

What is a Deprecation warning?

The Deprecation warning is a Python warning used to warn users about deprecated resources. Usually, the Python warnings are raised by default, but in the case of the Deprecation warning, it is presented by the deprecated sources and can be eliminated by default. A variable or a command line can be used to observe this warning.

Syntax for the command line:

-Wa
Syntax for the variable:
PYTHONWARNINGS

What is Deprecationwarning: executable_path has been deprecated?

The Deprecationwarning: executable_path has been deprecated is an error warning raised upon using the executable_path argument in the selenium version 4.0.

Syntax for the command line:

From selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()

driver.get("http://www.python.org")
driver.find_element(By.NAME, 'q').send_keys('Jane Doe')

The above code set will raise the Deprecationwarning: executable_path has been deprecated error warning as the selenium version 4.0 does not support it.

How to resolve the Deprecationwarning: executable_path has been deprecated?

The Deprecationwarning: executable_path has been deprecated. The error warning can be quickly resolved by following the methods mentioned below.

Check the modules

One way to resolve the Deprecationwarning: executable_path has been deprecated error warning can be checking whether the proper modules have been installed. Sometimes, the Deprecationwarning: executable_path has been deprecated. An error warning may arise if modules like webdriver-manager and selenium are not installed. To resolve that, you may need to install these modules by using the pip. For that, you may use any installation commands mentioned below.

Syntax for the command line:

pip install webdriver-manager selenium --upgrade
pip3 install webdriver-manager selenium --upgrade
python3 -m pip install webdriver-manager selenium --upgrade

The above lines of commands can be used for python 3 and higher.

sudo pip3 install webdriver-manager selenium --upgrade
pip install webdriver-manager selenium --user --upgrade

The above commands can be used when the used command raises the permission error other than the Deprecationwarning: executable_path has been deprecated error warning.

Apart from the above commands, you can install the selenium with other commands like below.

python -m pip install webdriver-manager selenium --upgrade
py -m pip install webdriver-manager selenium --upgrade

To make sure the pip version is working properly you may use the following command line.

Checking for pip version

Use of newer service class

Another way to resolve the Deprecationwarning: executable_path has been deprecated error warning is to replace the current service class with another. For instance, you can replace the service class with a chrome class to resolve the Deprecationwarning: executable_path has been deprecated error warning.

Syntax:

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

driver.get("http://www.python.org")

time.sleep(2)

driver.close()

Passing keyword arguments

Another way to resolve the Deprecationwarning: executable_path has been deprecated error warning is to pass an object as a keyword argument to the class when instantiating the code.

Syntax:

import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.utils import ChromeType
driver = webdriver.Chrome(service=Service(
ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))

driver.get("http://www.python.org")

time.sleep(2)

driver.close()

The “service” class uses the “chromium” as a keyword argument in the above code.

Specify the correct path

Another way to resolve the Deprecationwarning: executable_path has been deprecated error warning is to specify the correct path to the executable codes.

Syntax:

import time
From selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.google.com")

time.sleep(2)

driver.close()

FAQs

What is deprecation?

Deprecation Syntax

Deprecation in Python is a library that helps in enabling automated deprecations. It uses the deprecated() function, which is used to wrap functions and provide proper warnings both in documentation and deprecation.
To install the deprecation, you need to use the following code.
Syntax:

What is selenium 4.0?

The Selenium in Python is an open-source suite of tools and an automated cross-browser web-testing application that allows users to test their website’s functionality on different browsers and perform cross-browser testing to check the consistency of the website functions across other browsers. The Selenium 4.0 is the newer version of the application. It is used by manual testing, which can be time-consuming and prone to errors.

What is the service class?

In Python, a service class is a group within the workload with similar goals, resource requirements, or business importance. The service classes table lists all the service classes defined within the service definition. The service class can be Name, Importance, Duration, etc.

Conclusion

This guide here has all the information that can help you find the causes for Deprecationwarning: executable_path has been deprecated error warning and the probable solutions that can help you resolve the error without any issues.

References

  1. Selenium 4.0

Follow us at PythonClear to learn more about solutions to general errors one may encounter while programming in Python.

Leave a Comment