Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
860 views
in Technique[技术] by (71.8m points)

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

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:UsersvikramworkspaceLDCest.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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 and calling a wrong method. In fact I am following the eclipse autocomplete :(. 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...