[Fix] AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’

Recently, I was trying to get Selenium working with Chrome but continuously I am seeing the below error in Python:

AttributeError: 'WebDriver' object has no attribute 'find_element_by_name'

I would discuss in detail that how I was able to solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’ in Python.

Why AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’ Occurred?

Error is seen because recently Selenium has released the latest 4.3.0 version and depreciated the commands find_element_by_* and find_elements_by_*

So as per Selenium official announcement, they have released the latest version 4.3.0 and removed the support for below commands:

find_element_by_* 
 find_elements_by_*

How to Solve AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’?

Use the find_element instead of find_element_by_name command. It would solve the error.

As Selenium has recently depreciated the commands find_element_by_* and find_elements_by_*, To solve the error, instead use the command, find_element. It would solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’. Below is the Selenium official update for find_element_by_* and find_elements_by_* commands removal:

Selenium 4.3.0
* Deprecated find_element_by_* and find_elements_by_* are now removed (#10712)

Use the below step by step process to solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’ Error.

Fix 1: Use the find_element Instead

To solve the issue, use the below command

find_element

Instead of find_element_by_* and find_elements_by_* commands.

Once you use the command find_element, it would solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’.

Below is the format, how to use the find_element command, to solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’:

driver.find_element("name", "q")

Conclusion

To Fix the error, Use the command find_element instead of find_element_by_name command. It would solve the AttributeError: ‘WebDriver’ object has no attribute ‘find_element_by_name’.