Python and Selenium Search for Text Outside of Tags

Report
Question

Please briefly explain why you feel this question should be reported .

Report Cancel

I’m trying to make a selenium script using python that is able to search for a specific text and click on it. Below is an example of the code I’m working with. In this example I’m searching for the string “Next” and clicking on it.

<div class="btn-container text-center">
<button id="btnNext" class="btn btn-lg btn-primary btn-block">Next</button>
 </div>

So far I have tried the following:

driver.find_element_by_xpath("//*[@id='btnNext']").click()
driver.find_element_by_id('btnNext').click()
driver.find_element_by_xpath("//*[contains(text(),'" + 'Next' + "')]").click()
driver.find_element_by_xpath("//button[contains(.,'Next')]").click()

But no luck so far. Any suggestions? Thank you for all the help!

0
0 Answer 16 views 0