s9dw
s9dw

Reputation: 31

Selenium in Python - how do I click all buttons with a certain label?

So I want to click all the buttons with the button label "CLAIM", however it is not working. There are multiple buttons with this label so I tried making this:

like = driver.find_elements_by_class_name('CLAIM')
    for x in range(0,len(like)):
                if like[x].is_displayed():
                        like[x].click()

The button:

<div class="label">CLAIM</div>

I've tried using xpath but there are multiple buttons with this label. Can anyone help

Upvotes: 2

Views: 113

Answers (1)

Arundeep Chohan
Arundeep Chohan

Reputation: 9969

Simply find the divs with class label and text CLAIM and loop through them.

likes = driver.find_elements_by_xpath("//div[@class='label' and .='CLAIM']")
for like in likes:
    like.click()

Upvotes: 2

Related Questions