I need a little help finding exact text using xpath in webDriver.
Suppose I have html as follows.
<html><body> <table> <tr> <td><button>abcd</button></td> <td><button>abc</button></td> </tr> </table> </body></html>
Now I want to click the "abc" button
I used xpath as //button[contains(text(),'abc')] , but it always acts on the "abcd" button, since it also contains the text "abc". In this regard, I need a predicate or some other procedure that can search for exact text instead of text.
I also tried using //button[matches(text(),'abc')] , //button[matches($string,'abc')] , //button[Text='abc')] , //button[.='abc')] and many others, but none of them was designed to identify the "abc" button.
I do not know if there are any problems regarding my version of xpath, since I do not know about the version. But I am using java 1.6 JDK.
Although my exact scenario is not an example, similar logic should be applied.
Therefore, any help or suggestion would be greatly appreciated.
source share