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

后端 未结 8 649
暗喜
暗喜 2020-11-27 22:42

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         


        
相关标签:
8条回答
  • 2020-11-27 23:01

    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

    0 讨论(0)
  • 2020-11-27 23:07

    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.

    0 讨论(0)
提交回复
热议问题