I have the following xpath:
@innertext~'(?i:'+$datacolumnvalue+')']/../..
it uses a regular expression to do a case insensitive comparison.
Is there a way to use case insensitivity with an equal sign?
Case Insensitive with equal sign
Re: Case Insensitive with equal sign
No, the equals sign ("=") means both sides of the equation must be exactly the same. In this case, Ranorex will interpret every character in your expression as a literal character when comparing.
The RegEx sign ("~") is the only way to do what you are attempting.
The RegEx sign ("~") is the only way to do what you are attempting.
Re: Case Insensitive with equal sign
Hi,
I dont understand. It is not an equation, I have that as part of my path. In some cases is incorrectly identifying strings because it is a RegEx. What I want is to find the exact string regardless of casing. Thanks.
//div[ @innertext~'(?i:'+$datacolumnvalue+')']
I dont understand. It is not an equation, I have that as part of my path. In some cases is incorrectly identifying strings because it is a RegEx. What I want is to find the exact string regardless of casing. Thanks.
//div[ @innertext~'(?i:'+$datacolumnvalue+')']
Re: Case Insensitive with equal sign
It is an expression, a logical equality expression. Ranorex treats the path attributes as expressions at runtime.
As I said, you cannot search for case insensitive strings with the equals ("=") sign, only with the RegEx ("~") sign.
If your current path is finding objects that you don't want it to find, then you will need to make your path more unique.
Without being able to see your application, I can't give you anymore direction than that, unfortunately. If you could post a snapshot of your application under test it would help us see your issue better. http://www.ranorex.com/support/user-gui ... files.html
As I said, you cannot search for case insensitive strings with the equals ("=") sign, only with the RegEx ("~") sign.
If your current path is finding objects that you don't want it to find, then you will need to make your path more unique.
Without being able to see your application, I can't give you anymore direction than that, unfortunately. If you could post a snapshot of your application under test it would help us see your issue better. http://www.ranorex.com/support/user-gui ... files.html
Shortcuts usually aren't...
Re: Case Insensitive with equal sign
The path is correct, it is not a problem with the uniqueness.
It is matching for example JAP in a string like Japan and I only want it to match exact strings.
Thanks.
It is matching for example JAP in a string like Japan and I only want it to match exact strings.
Thanks.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Case Insensitive with equal sign
Hi Mayra,
I am not sure I got your question, but if you just want that the exact string matches you need to use the normal "=", like: @innertext='Japan'.
Regards,
Markus
I am not sure I got your question, but if you just want that the exact string matches you need to use the normal "=", like: @innertext='Japan'.
Regards,
Markus
Re: Case Insensitive with equal sign
If you want to match only exact strings in an insensitive manner you should use the ^ and $ delimiters for start and end of line respectively.Mayra wrote:The path is correct, it is not a problem with the uniqueness.
It is matching for example JAP in a string like Japan and I only want it to match exact strings.
Thanks.
So your regex would become:
//div[ @innertext~'^(?i:'+$datacolumnvalue+')$']
Michael Rollins
Re: Case Insensitive with equal sign
Thanks Michael, looks like that is what I need
Re: Case Insensitive with equal sign
I have one case where the regular expression is not working. I got it down to be the '(' within the string that I am using in the value to be found, example:
tag[@innertext~'^(?i:'+$graphnodelabel+')$']
if graphnodelabel contains a ( then the value is not found, example not found:
tag[@innertext~'^(?i:'+'smtp (TCP:25)'+')$']
Is there a way to use ( within the string to be found in the regular expression?
Thanks.
tag[@innertext~'^(?i:'+$graphnodelabel+')$']
if graphnodelabel contains a ( then the value is not found, example not found:
tag[@innertext~'^(?i:'+'smtp (TCP:25)'+')$']
Is there a way to use ( within the string to be found in the regular expression?
Thanks.
Re: Case Insensitive with equal sign
The problem is, that the parentheses are reserved characters in regex, which must be escaped. I think the easiest way around would be to add \ in front of each parentheses in your test data, from which you fill that $graphnodelabel variable?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Case Insensitive with equal sign
odklizec is correct, you need to escape the parenthesis in your data. I've had the same issue with phone numbers in my data set (US phone numbers have "(XXX) XXX-XXXX" format).
I use SQL Server for my data, so in my queries I just have an extra column called "Escaped_PhoneNumber" that I populate by replacing each "(" with "\(" and each ")" with "\)" so that I now have the regular phone number for validation comparisons, and the escaped one for XPath regex expressions.
If you are using Excel, you can add another column that is an expression from the raw column that does the same thing I did above.
If you are using CSV or simple data connectors, you will need to do it manually for each row. (This is one reason I recommend at least Excel, but really a true database is best and SQL Server Express is free and integrates directly with Ranorex.)
I use SQL Server for my data, so in my queries I just have an extra column called "Escaped_PhoneNumber" that I populate by replacing each "(" with "\(" and each ")" with "\)" so that I now have the regular phone number for validation comparisons, and the escaped one for XPath regex expressions.
If you are using Excel, you can add another column that is an expression from the raw column that does the same thing I did above.
If you are using CSV or simple data connectors, you will need to do it manually for each row. (This is one reason I recommend at least Excel, but really a true database is best and SQL Server Express is free and integrates directly with Ranorex.)
Shortcuts usually aren't...