I need a little help regarding searching an exact text using xpath in webDriver.
Suppose i have the 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 button "abc"
I used xpath as //button[contains(text(),'abc')]
but it is always performing on button "abcd" as it also contain the text "abc". In this regards I need a predicate or some other procedure which can search exact text instead of containing text.
I also tried with //button[matches(text(),'abc')]
, //button[matches($string,'abc')]
, //button[Text='abc')]
, //button[.='abc')]
and many more but none of these worked out to identify "abc" button.
I do not know if there is any problem regarding my xpath version as I'm not aware of the version. But I'm using java 1.6 JDK.
Though my exact scenario is not the example shown but similar logic needs to be applied.
Hence any help or suggestion would be highly appreciated.