How do I find an element that contains specific text in Selenium WebDriver (Python)?

Try the following:

driver.find_elements_by_xpath("//*[contains(text(), 'My Button')]")

You could try an XPath expression like:

'//div[contains(text(), "{0}") and @class="inner"]'.format(text)