I have been running Automated Tests apart of builds for some times now, and a series of tests surrounding email validation kept failing. The issue I have found is due to a javascript error that is thrown explaining that Selenium cannot search for a '@' in text within an XPath.
I came across this SO Question which nicely confirmed to me that characters cannot be searched for within text via XPath in Selenium as standard.
My question is, has anyone found a way around this?
For example, I would like to be able to find an element with the following text field:
<h1>"personA@email.com.au.personB@email.com.au - The separator '@' is either in an invalid position or is missing from the address."</h1>
And my current XPath (clearly won't work with the presence of symbols) that throws a javascript error is (where errorText is just the above string):
"//*[contains(text(), '" + errorText + "')]"
And just for fun, if the javascript error helps:
[14/01/2013 - 14:35:00.1820111] : InvalidSelectorError: Unable to locate an element with the xpath expression //*[contains(text(), 'personA@email.com.au.personB@email.com.au - The separator '@' is either in an invalid position or is missing from the address.')] because of the following error:
Error: Bad token: @
[EDIT]
I have looked into the SO Question that suggests I need to surround my input text with double quotes, however doing this still causes the above javascript error to throw. I still am under the impression the @ symbol is the issue here and can see no obvious way to search via text including it.