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?
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.