vendredi 20 juillet 2018

Selenium + Python. How to click on checkbox?

I have problem that I don't know how to solve. I need to set to TRUE checkbox declared as:

<label class="checkbox-group__label" for="5b51a49146e0fb0001bd7b5e-SJ6k5D714Q">
    ::before
    <span>
        ....
    </span>
</label>

Because those element are in list I created in python loop that iterates over elements:

consents = self.driver.find_elements_by_css_selector('input.checkbox-group__input')
for consent in consents:
    checkbox = consent.find_element_by_css_selector('label.checkbox-group__label::before')
    checkbox.click()

But every time I got error:

selenium.common.exceptions.NoSuchElementException

I tried also use xpath, but the effect was the same :(




Aucun commentaire:

Enregistrer un commentaire