Selenium XPath methods locating elements based on text content.

Here are the mostly used useful text methods and exmaple in Xpath.

text() — //a[text()=’text’]
contains(text(), “value”) — //button[contains(text(),’value’)]
starts-with(text(), “value”) — //a[starts-with(text(),’value’)]
ends-with(text(), “value”) — //a[ends-with(text(),’value’)]
normalize-space(text()) — //a[normalize-space(text())=’text’]
trim(text()) — trim(text())

No responses yet