I've been having serious issues detecting elements in a particular section of a document. The issue is regarding a large menu presented as a sequence of buttons that contain both image and text in that order to this one:
<button type="button" id="ext-gen375" class=" x-btn-text">
<img style="height:13px" src="inc/FAST/images/icons/Transaction.png">
Transactions
</button>
I want to select the button using its text contents, the issue is that there are other buttons that have similar names, i.e."Policy" and "Policy Address". The ideal solution would be to match the text avoiding the use of contains or other substring functions, but I've been struggling to do so. I have tried several different expressions that seem fine on http://xpather.com/ but do not work on Mozilla or Chrome at all.
//button[text()[normalize-space()="Transactions"]]
//button[normalize-space(text())="Transactions"]
//button[normalize-space(.)="Transactions"]
//button[text()[translate(normalize-space(), " 	
","")="Transactions"]]
Thanks in advance guys.
Edit1:
Prophet had an excellent suggestion to use the tag in the search. Unfortunately, similar buttons share the same icon.
Edit2
Based on Siebe's answer I was able to look a deep further into the situation. My goal was to have a working XPath 1.0 expression for automation in Selenium, but I was using Chrome and Firefox to test the expressions. For some reason on those browsers, Non-Breaking Spaces in a text will not match the common whitespace character or any of the characters bellow:
' ', ' ', ' ', '\u00a0'
After many hours trying to find something, I opted to start a Selenium WebDriver section and perform the tests there and to my surprise, the XPath bellow worked using the Chrome Driver:
//button[text()[translate(., "\u00a0", "")="Transactions"]]
While that expression works for Selenium automation projects, it really reinforces the impact that different implementations of the same tool can have on your project. Thanks again to everyone that replied.