问题描述
我正在尝试使用 python 在 Selenium webdriver 中使用 click 命令.但我收到以下错误.有人可以帮我吗?
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'
这是我的程序
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
推荐答案
感谢您的帮助.我为自己找到了答案.由Dan Niero"给出的想法
Thanks for helping out. I found the answer for myself. Idea given by "Dan Niero"
问题是,我使用的是 driver.find_element[s]
而不是 driver.find_element
.所以 one s 会产生差异并调用错误的方法.事实上,我正在关注 Eclipse 自动完成 :(.显然 driver.find_elements_by_link_text
返回列表,所以如果我发送点击事件,它不会理解.
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
-维克拉姆
这篇关于AttributeError: 'list' 对象没有属性 'click' - Selenium Webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!