Xpath Function Using Text
Xpath Text():-
This keyword is used to create expressions for XPath in Selenium when we have a text defined in an
HTML tag and we wish to identify element via text. This comes really handy when the other attribute values change dynamically with no
substantial part of the attribute value that can be used via Starts-with or Contains.
In the below mentioned examples, we have use the text on the button to identify the element. Here two instances of the examples are used, one where the text is exact matched, whereas the other
where the text is matched partially using contains keyword.
Example 1: Xpath= //button[text()='Signup for Free']
Example 2: Xpath=//button[contains(text(),'Signup' )]