AttributeError: 'list' object has no attribute 'click' - Selenium Webdriver

python attributeerror: object has no attribute
attributeerror django
typeerror python
python import attributeerror
python custom exception
indexerror python
attributeerror pplayoutblank
filenotfounderror python

I am trying to use click command in Selenium webdriver using python. But I am getting the below error. Can some one help me?

Traceback (most recent call last):
File "C:\Users\vikram\workspace\LDC\test.py", line 13, in <module>
driver.find_elements_by_link_text("MISCQA Misc Tests").click()
AttributeError: 'list' object has no attribute 'click'

Here is my program

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By 
from selenium.common.exceptions import NoSuchElementException 
from selenium.webdriver.support.ui import WebDriverWait
import config

url = config.config.get('url')

driver = webdriver.Ie()
driver.get(url)

driver.find_elements_by_link_text("MISCQA Misc Tests").click()

driver.close()

I think I am missing some thing. Please suggest me

Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"

The problem is, I am using driver.find_element[s] instead of driver.find_element. So one s makes difference. In fact I am following the eclipse :(. Obviously driver.find_elements_by_link_text returns list so If i send click event it wont understand.

Thanks for helping and sorry for my bad question

-Vikram

6. Built-in Exceptions, exception AttributeError ¶. Raised when an attribute reference (see Attribute references) or assignment fails. (When an object does not support  The AttributeError in Python is raised when an invalid attribute reference is made, or when an attribute assignment fails. While most objects support attributes, those that do not will merely raise a TypeError when an attribute access attempt is made.

maybe driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click() or another index...

I don't know Selenium, but I guess find_elements_by_link_text is finding more than one thing, or maybe the method always return a list rather than a single object. If you are absolutely sure that only one object should be the result of your search, than just use [0] as I mentioned, if you can't assume that there will be only one object, than you need to come up with a stronger strategy

Python Exception Handling - AttributeError, The AttributeError in Python is raised when an invalid attribute reference is made, or when an attribute assignment fails. While most objects  I usually think about attributes as nouns that belong to an object. For example, “the student has two eyes ”. But in Python, an attribute can also be an action that an object can perform—“The cat can jump ”. An attribute in Python means some property that is associated with a particular type of object.

The part of your code,

driver.find_elements_by_link_text("MISCQA Misc Tests")

is returning back a list and not an object of the selenium webdriver (what you want, object of the class having the function "click()" ) .

Most likely, the elements of the list would be the objects.

Print the list after that part of the code and check if the elements of the list are the ones that you need.

Python: AttributeError, These errors yields to the program not executed. One of the error in Python mostly occurs is “ AttributeError “. AttributeError can be defined as an error that is raised  AttributeError: 'NoneType' object has no attribute 'display_id' Copy link Quote reply Owner pycaret commented Apr 21, 2020. Hi, To avoid this please pass verbose

if you want single element so u can use:

driver.find_element_by_link_text("MISCQA Misc Tests")

or if you want whole list, then:

for x in self.driver.find_elements_by_link_text("MISCQA Misc Tests"):
    link = webdriver.ActionChains(self.driver).move_to_element(x).click(x).perform()

Getting Started with Python: Attribute Error, can be defined as an error that is raised when an attribute reference or assignment fails. System information Have I written custom code (as opposed to using example directory): no OS Platform and Distribution: 8.04.3 LTS (Bionic Beaver) TensorFlow backend (yes / no): yes TensorFlow version: 2.0.0 (gpu) Keras version: 2.2.5 Py

if the attribute of "MISCQA Misc Tests" only has one,You can try to change elements into element in this code 'driver.find_elements_by_link_text("MISCQA Misc Tests")' Hope the problem will be fix

Error Encyclopedia, Attribute Error. Attributes in Python. I usually think about attributes as nouns that belong to an object. For example, “the student has two eyes”. But in Python, an  Circular imports cause problems, but Python has ways to mitigate it built-in. The problem is when you run python a.py, it runs a.py but not mark it imported as a module. So in turn a.py-> imports module b -> imports module a -> imports module b.

Error Encyclopedia, This happens because the scipy module doesn't have any attribute named sparse . That attribute only gets defined when you import  Concrete exceptions¶ The following exceptions are the exceptions that are usually raised. exception AssertionError¶ Raised when an assert statement fails. exception AttributeError¶ Raised when an attribute reference (see Attribute references) or assignment fails.

Why does this AttributeError in python occur?, I usually think about attributes as nouns that belong to an object.An attribute in Python means some property that is associated with a particular type of object.

Python AttributeError, AttributeError: 'int' object has no attribute 'clear' #95. Closed. dandan0503 opened this issue on Dec 5, 2019 · 6 comments. Closed 

Comments
  • driver.find_elements_by_link_text("MISCQA Misc Tests") returns list, not callable object
  • I used the above statement but no luck. do you think that I didn't import a correct class for it.
  • Vikram, I don't know this Selenium, but the error message you got clearly states that you got a LIST back, so you need to access the elements inside that list... What other error you get when you try to do so?
  • This is the output which I get [<selenium.webdriver.remote.webelement.WebElement object at 0x0000000002D9E630>]
  • WebDriver driver = new InternetExplorerDriver(); driver.get(url); WebElement element = driver.findElement(By.linkText("Miscellaneous Tests")); element.click(); - This is the code in Java. I want to simulate the same in Selenium Python
  • Yes. these are objects itself. So, just iterate over the list and call the click() method over them. For example, driver.find_elements_by_link_text("MISCQA Misc Tests")[0].click()
  • ^I meant not an object of the selenium webdriver he expects. Edited to make it more precise. Thank you for pointing that out. :)
  • isClickable() returns boolean so it doesn't require. Anyways I found the answer