I cant click in a button and selenium not finding element selenium python

Issue

Web page inspect

I want the bot to click on Ya, Benar
I tried this but it didn’t work for me:

driver.find_elements_by_xpath("//*[contains(text(), 'Ya, Benar')]").click()

Solution

If you want to user find_elements_by_xpath procede like this:

buttons = driver.find_elements_by_xpath("//*[contains(text(), 'Ya, Benar')]")
    
for btn in buttons:
    btn.click()

it means that find_elements_by_xpath returns an array

Answered By – Mbula Mboma Jean gilbert

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published