contains text in selenium code example
Example 1: contains text xpath
//*[contains(text(),'ABC')]
Example 2: locate element using text
The only locator that works with text is xpath.
Matching exact text : //tag[.=‘text’]
Matching partial text : //tag[contains(text(), ’text’)]