XPath: Matching a node element having a specific text
Problem : To identify uniquely a GUI element having a text "Enterprise Sample" within its <a> tag
Solution : The page source of the web page shows the element as <a href="clickme.html">Enterprise Sample</a> . Use the below command in xpath checker to uniquely identify this element
| //a[contains(text(),"Enterprise")] |
In layman's term, the above command will look
- first for all occurrence of <a> tag within the web page
- then matches the value of <a> tag with user's text (here "Enterprise")