简体   繁体   English

我有一个按钮列表,但我无法访问它们

[英]I have a list of buttons and I can't access them

I have a list of buttons and I am trying to get all of them into an array to click one by one.我有一个按钮列表,我试图将它们全部放入一个数组中以逐个单击。

<ul> 
<li class="listFUTItem has-auction-data selected"><button class="ut-image-button-control btnAction"></button></li>
<li class="listFUTItem has-auction-data"><button class="ut-image-button-control btnAction"></button></li>
<li class="listFUTItem has-auction-data"><button class="ut-image-button-control btnAction"></button></li>
</ul>

I tried something like this.我试过这样的事情。

clicks = (driver.find_elements_by_class_name('ut-image-button-control'))
for c in clicks:
    c.click()

But it didn't work.但它没有用。 Can someone help me with a new code (a new find_element_by....)or something?有人可以帮我写一个新代码(一个新的 find_element_by ....)或其他什么吗?

UPDATE:更新:

在此处输入图片说明

This is the list I want to click on each button.这是我想点击每个按钮的列表。

To click on each button.Induce WebDriverWait () and visibility_of_all_elements_located () and following css selector.单击每个按钮。Induce WebDriverWait () 和visibility_of_all_elements_located () 以及以下css 选择器。

clicks=WebDriverWait(driver,10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR,"button.ut-image-button-control.btnAction")))
for c in clicks:
    c.click()

You need to import following libraries.您需要导入以下库。

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以为未知数量的按钮列表创建破折号回调吗? 即不知道列表将有多少按钮以及需要多少回调 - Can I create dash callbacks for a list of unknown number of buttons. I.e don't know how many buttons the list will have and how many callbacks needed 为什么我不能以编程方式播放我下载的MIDI文件,但是当我手动下载时我可以播放它们? - Why can't I play the MIDI files I have downloaded programmatically, but I can play them when I download them manually? 为什么我不能访问列表元素 - Why can't I access list element 我有一个xpath列表,如何在不同的选项卡中打开它们? - I have a list of xpaths, how can I open each one of them in a different tab? 为什么我不能连接这个列表中的项目,但我可以将它们相乘? - Why can't I concatenate items in this list but I can multiply them? 如何堆叠按钮,而不是在Tkinter中将它们排队? - How can I stack buttons rather than queue them in Tkinter? 我如何通过网络抓取某些没有附加属性的单词? - How can I web scrape certain words that don't have an attribute attached to them? 如何为没有标准库的Python安装标准库? - How can I install the standard libraries for a Python that doesn't have them? 为什么我不能通过Python中的键访问列表? - Why can't I access a list by its key in Python? 为什么我无法访问在我的方法中生成的这个列表? - Why can't I access this list generated in my method?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM