- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Selenium WebDriver Error: AttributeError: 'list' object has no attribute 'click'
We can get the Selenium webdriver error: AttributeError: 'list' object has no attribute 'click' while working on a test. Let us see an example of code where we have encountered such an error.
Example
Code Implementation
from selenium import webdriver driver = webdriver.Chrome(executable_path='../drivers/chromedriver') #implicit wait driver.implicitly_wait(0.5) #url launch driver.get("https://www.tutorialspoint.com/index.htm") #identify an element m = driver.find_elements_by_name('search') m.click() #browser quit driver.quit()
Output
In the above code, we have got the error as we have used find_elements_by_name instead of find_element_by_name to perform a click operation on a single element. The method find_elements_by_name returns a list of elements.
Here, we want to perform click operation on an element, so the webdriver fails to identify the element on which it should perform the click. In this scenario, if we want to use the find_elements_by_name method, we have to explicitly mention the index of the element to be clicked.
Example
Code Implementation
from selenium import webdriver driver = webdriver.Chrome(executable_path='../drivers/chromedriver') #implicit wait driver.implicitly_wait(0.5) #url launch driver.get("https://www.tutorialspoint.com/index.htm") #identify an element with find_element_by_name m = driver.find_element_by_name('search') m.click() m.send_keys('Selenium') s = m.get_attribute('value') print('Value entered: ' + s) #browser quit driver.quit()
Output
- Related Articles
- Selenium Webdriver submit() vs click().
- How to click on across browsers using Selenium Webdriver?
- How to use Selenium webdriver to click google search?
- How to click on hidden element in Selenium WebDriver?
- How to click on image in selenium webdriver Python?
- How to handle SSL certificate error using Selenium WebDriver?
- WebDriver click() vs JavaScript click().
- How to click Allow on Show Notifications popup using Selenium Webdriver?
- How to click on a link using Selenium webdriver in Python.
- How do you click on an element which is hidden using Selenium WebDriver?
- How can I verify Error Message on a webpage using Selenium Webdriver?
- How to get an attribute value of an element in Selenium Webdriver?
- Get attribute list from MongoDB object?
- Selenium RC vs Selenium webdriver.
- How to verify an attribute is present in an element using Selenium WebDriver?

Advertisements