contains()
Example: //li[contains(text(),'Apple')]
selects all li elements containing 'Apple'.
starts-with()
Example: //span[starts-with(text(),'Book')]
selects all spans starting with 'Book'.
ends-with()
Example: //span[ends-with(text(),'B')]
selects all spans ending with 'B'.
Practice Tool
Try using these functions in our XPath practice tool for QA testers.