<label class="btn btn-default btn-sm ng-pristine ng-valid" ng-model="radio.activePane" btn-radio="1">
<i class="glyphicon glyphicon-th"></i>
Datos
</label>
I’m trying to find this element and then click on it. However I can’t find it and I don’t know exactly why.
I have tried this code but I get NoSuchElementException. I would like to find it by the text if it is possible. The class and the rest of the tags may change.
driver.find_element(By.XPATH, "//label[contains(text(), 'Datos')]").click()
Any ideas of how can I find the element and click on it?
2
Answers
Use either of the two below XPath expressions:
//*[text()[contains(.,'Datos')]]
or//label[contains(.,'Datos')]
or:
If you are getting
NoSuchElementException
you can try the explicitWaitOR