Page 1 of 1

Need some help with RxPath

Posted: Thu Dec 03, 2009 7:44 pm
by ohm
I am trying to validate a browser URL.
Functionality is application should be redirected to 'www.xyz.com' URL which cannont contain certain charecters (ERROR, DROP).

As an example:
Browser URL test should read anything but 'ERROR' or 'DROP'
If it says
http://www.xyz.com/PROCESS.394739 (pass)
http://www.xyz.com/ERROR343949 (should fail)
http://www.xyz.com/483949DROP (should fail)

I tried to use the following RxPath: *[^(ERROR|DROP)]*
Didnt work.

May be there is some other way.

Please help.
Thanks in advance.

Re: Need some help with RxPath

Posted: Fri Dec 04, 2009 8:12 am
by Support Team
Hi Ohm!

Alternative:
Simply get the Browser Url Ranorex.Text element and verify the TextValue.

Let`s say TextURL is your Ranorex.Text element. Use e.g. the String.Contains() method to check if there`s DROP or ERROR in it.
// Sample Code
Ranorex.Text TextURL = "/form[@title~'^Post\\ a\\ reply']/element/toolbar[2]/combobox/text[1]";
bool pass = !TextURL.TextValue.Contains("DROP") && !TextURL.TextValue.Contains("ERROR");
			
if(pass==false)
    Ranorex.Report.Error("wrong URL");
Regards,
Christian
Ranorex Team

Re: Need some help with RxPath

Posted: Fri Dec 04, 2009 10:28 am
by Support Team
ohm wrote:I tried to use the following RxPath: *[^(ERROR|DROP)]*
You cant use the [^abc] here, because that means "do not match any of the following characters".

However, you can use "Zero-width negative lookahead assertions" (see http://msdn.microsoft.com/en-us/library/bs2twtah.aspx). For your example the regex should be the following:
^((?!ERROR|DROP).)*$

The above regex matches strings with arbitrary characters in it, unless a character has "ERROR" or "DROP" in front of it.

Regards,
Alex
Ranorex Support Team

Re: Need some help with RxPath

Posted: Fri Dec 04, 2009 3:15 pm
by ohm
Thank you both.

It's working great.