Hi,
I want to ensure that the value of an adapter in the xpath does not contain a particular word. Can you please advise how I do this? I had a look at the page below but couldn't see an explanation for what it is that I am trying to do
http://www.ranorex.com/support/user-gui ... xpath.html
'!=' means 'not equal' and '~' means 'contains' so I thought combining the two would give me the desired result i.e. '!~' but it turns out that this doesn't seem to be valid syntax.
Thanks.
How to express not contains in xpath
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to express not contains in xpath
Hi,
In general the RxPath and the attribute should be used to uniquely find the element, in your case you will find "all" elements which don't contain the word and I think you will find many elements.
I would suggest checking the string with one of the normal C# methods in UserCode or with a Validation action (AttrubuteNotContains).
Regards,
Markus
Ranorex Support Team
So the thing is that you want to ensure that a particular word is not in a specific attribute of a specific element?Can you please advise how I do this?
In general the RxPath and the attribute should be used to uniquely find the element, in your case you will find "all" elements which don't contain the word and I think you will find many elements.
I would suggest checking the string with one of the normal C# methods in UserCode or with a Validation action (AttrubuteNotContains).
Regards,
Markus
Ranorex Support Team
Re: How to express not contains in xpath
Hi Markus,
Sorry I didn't explain very well. What I want to ensure is that the value of an attribute in the xpath does not contain a particular word.
For example, if I want to find all buttons where the text attribute contains the word 'Add', I would express it like this:
/button[@text~'Add']
So what if I want to find all buttons where the text attribute does not contain the word 'Add'. How would I express this in the path? /button[@text!~'Add'] does not work.
When validating within my recording, I am trying to stick to only using 'validate exists' where possible. So this means that the not contains expression must be expressed in the xpath itself. If there is no way of doing this within the path then I will use the validate not contains action in the recording. But i just wanted to check first.
Thanks.
Sorry I didn't explain very well. What I want to ensure is that the value of an attribute in the xpath does not contain a particular word.
For example, if I want to find all buttons where the text attribute contains the word 'Add', I would express it like this:
/button[@text~'Add']
So what if I want to find all buttons where the text attribute does not contain the word 'Add'. How would I express this in the path? /button[@text!~'Add'] does not work.
When validating within my recording, I am trying to stick to only using 'validate exists' where possible. So this means that the not contains expression must be expressed in the xpath itself. If there is no way of doing this within the path then I will use the validate not contains action in the recording. But i just wanted to check first.
Thanks.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to express not contains in xpath
Hi,
You can overcome your issue using follwoing regular expression within your attribute equation in your RanoreXPath:
Regards,
Tobias
Ranorex Team
The "!~" will be supported within one of our future releases.Support Team wrote:So what if I want to find all buttons where the text attribute does not contain the word 'Add'. How would I express this in the path? /button[@text!~'Add'] does not work.
You can overcome your issue using follwoing regular expression within your attribute equation in your RanoreXPath:
Code: Select all
/button[@text~'^((?!Add).)*$']
Tobias
Ranorex Team
Re: How to express not contains in xpath
ok thanks