[英]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.