selenium find by text code example
Example 1: selenium find button by text
browser.find_element_by_xpath('//button[normalize-space()="BUTTON-TEXT-HERE"]')
Example 2: selenium find element by content
driver.find_elements_by_xpath("//*[contains(text(), 'My Button')]")
Example 3: how to locate element by using text
The only locator that works with text is xpath.
Matching exact text : //tag[.=‘text’]
Matching partial text : //tag[contains(text(), ’text’)]