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.
Need some help with RxPath
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need some help with RxPath
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.
Christian
Ranorex Team
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need some help with RxPath
You cant use the [^abc] here, because that means "do not match any of the following characters".ohm wrote:I tried to use the following RxPath: *[^(ERROR|DROP)]*
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
Thank you both.
It's working great.
It's working great.