Home > Software design >  how to select jquery yes or no using selenium python?
how to select jquery yes or no using selenium python?

Time:08-26

how can I click on yes or no, there's no id or class-name o of any element to select by look the picture i tried elem = browser.find_element(By.TAG_NAME, 'YES').click() but i didn't work I just wanted to click yes, I tried also to click enter but I have to select yes or no first

jquery

html

CodePudding user response:

By using Xpath and including text(), you should be able to get that element and click on it. If there are other buttons in the page with the text "yes", it will get the first one, so make sure there is only one.

In Python use the following code:

browser.find_element(By.XPATH, '//div/button[text()="yes"]')

Read more here: https://selenium-python.readthedocs.io/locating-elements.html

CodePudding user response:

solved the problem with your method but without div just browser.find_element(By.XPATH, '//button[text()="yes"]').click() thank you Ahmad Audi

  • Related