gpt4 book ai didi

python - AttributeError: 'list' 对象没有属性 'click' - 使用 Python 的 Selenium Webdriver

转载 作者:行者123 更新时间:2023-11-30 22:01:37 25 4
gpt4 key购买 nike

我正在尝试使用 python 在 Selenium webdriver 中使用 click 命令。但我收到以下错误。有人能帮我吗?

Traceback (most recent call last):
File "C:/Users/Sagnik/Desktop/pp.py", line 13, in <module>
user.click()
AttributeError: 'list' object has no attribute 'click'

下面是我的代码:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('url')

input("Anything after scanning QR code")

names = ["ABC", "DEF"]

for name in names:
print(name)
user = driver.find_elements_by_xpath('//span[@title = "{0}"]'.format(name))

user.click()

我想我错过了一些东西。请推荐我

最佳答案

find_elements_by_xpath()

返回结果列表。也许您想要 find_element_by_xpath 来代替?

关于python - AttributeError: 'list' 对象没有属性 'click' - 使用 Python 的 Selenium Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54000871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com