Need some help with RxPath

Ranorex Spy, Recorder, and Studio.
ohm
Posts: 27
Joined: Thu Dec 03, 2009 7:27 pm

Need some help with RxPath

Post by ohm » Thu Dec 03, 2009 7:44 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need some help with RxPath

Post by Support Team » Fri Dec 04, 2009 8:12 am

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
.
Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need some help with RxPath

Post by Support Team » Fri Dec 04, 2009 10:28 am

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
.
Image

ohm
Posts: 27
Joined: Thu Dec 03, 2009 7:27 pm

Re: Need some help with RxPath

Post by ohm » Fri Dec 04, 2009 3:15 pm

Thank you both.

It's working great.