Extraction/validation Rule Code

Is there anyway we can get coded versions of the built in extractio/validation rules? I am writing some custom extraction rules and mine are only slight changes to the build in ones so it would nice to not have to write all of the code. VB code would be cool, but C# is fine now that I found a working convert. http://www.dotnettaxi.com/tools/converter.aspx Thank you to the person here who posted it!!

~Todd

[416 byte] By [fodnick96] at [2007-12-21]
# 1
I don't think we are going to release the source for those rules but there are some samples on the web. But the code is all managed and not obfuscated so if you are resourceful you could probably figure out how they work.
ChrisPatMSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...
# 2
could u then provide an example in VB to remove text from an html response that starts with "id=" and ends with ","?

~Todd

fodnick96 at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...
# 3
See my answer in the following post http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=509966&SiteID=1
ChrisPatMSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...
# 4
The built in extract text is not working as I hoped. There is a bug such that it fails even if the required value is set to false. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=198822&SiteID=1
I need to write a custom one, but I was unsure of how to do this easily. This was more of a coding block than anything. I was thinking regular expressions. Any help would be great appreciated.

~Todd

fodnick96 at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...
# 5

you can find some detailed information about creating a custom extraction rule on the following site http://blogs.msnd.com/joshch as far as parsing out your text goes:

Here is an expample of looking for a tag with a specific attribute. Then grabbing the value from one of the attributes and parsing it to get a specific part of te string. The tag in question will look like the following

<a id="Categories_repCategories_ctl01_lnkCategory" href="Products.aspx?page=0&amp;categoryId=BIRDS">Birds</a>

and the code to get the category id out of it looks like this:

public class ExtractRandomCategory : ExtractionRule { public override void Extract(object sender, ExtractionEventArgs e) { List linkTags = new List(); e.Success = false; if (e.Response.IsHtml) { foreach (HtmlTag tag in e.Response.HtmlDocument.GetFilteredHtmlTags( "a" )) { if (tag.GetAttributeValueAsString("id").StartsWith("Categories")) { linkTags.Add(tag); } } } Random rand = new Random(); int linkIndex = rand.Next(linkTags.Count); HtmlTag linkTag = linkTags[linkIndex]; string linkValue = linkTag.GetAttributeValueAsString("href"); string categoryId; string categoryIdParamName = "categoryId="; if (linkValue.IndexOf(categoryIdParamName) != -1) { categoryId = linkValue.Substring((linkValue.IndexOf(categoryIdParamName) + categoryIdParamName.Length)); e.WebTest.Context.Add(this.ContextParameterName, categoryId); e.Success = true; } else { e.Success = false; } return; } public override string RuleName { get { return "Extract Ramdom Category Id"; } } }
ChrisPatMSFT at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...

Visual Studio Team System

Site Classified