Need some help with RxPath : Automation Tools

Need some help with RxPath

Ranorex Spy, Recorder, and Studio.

Need some help with RxPath

Postby ohm » Thu Dec 03, 2009 8: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.
ohm
 
Posts: 27
Joined: Thu Dec 03, 2009 8:27 pm

Re: Need some help with RxPath

Postby Support Team » Fri Dec 04, 2009 9: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
User avatar
Support Team
Site Admin
 
Posts: 4289
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Need some help with RxPath

Postby Support Team » Fri Dec 04, 2009 11: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
User avatar
Support Team
Site Admin
 
Posts: 4289
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Re: Need some help with RxPath

Postby ohm » Fri Dec 04, 2009 4:15 pm

Thank you both.

It's working great.
ohm
 
Posts: 27
Joined: Thu Dec 03, 2009 8:27 pm


Return to Automation Tools

Who is online

Users browsing this forum: No registered users and 0 guests