custom extraction rule to return collection.
I am trying to find out how to return a collection type (array or arraylist) from custom extraction rule and use that collection in the coded script or declarative test. Also, when I tried to use my own custom extraction rule (called Class1), I am getting the following error message "Class1 Extraction Could not create instance of rule class 'Class1' :Object reference not set to an instance of an object."
[417 byte] By [
Bart1] at [2007-12-17]
Bart,
Try running your web test from the Test View tool window (Test menu -> Windows -> Test View) and selecting Debug Selection. This will run your web test under the debugger to help you figure out what's causing that null reference exception.
As for using a collection created by an extraction rule, you can have the extraction rule place the collection in the context and the coded web test can pull the collection back out of the context later in the web test. That's, in fact, what I did to implement the ExtractHiddenFields extraction rule. You might notice a String[] in the context under a name like $HIDDEN1 which is used internally to keep track of which hidden fields were extracted from a page, so I can clean them up the next time ExtractHiddenFields runs.
Josh
I see. Context is the place to go.
Is the implementation of ExtractHiddenFields (source code or sample code) available some where? Also, is there a way to share this data among different web tests? Context appears to be within the scope of one web test only.
Sorry, the source code to ExtractHiddenFields is not available, but when you inherit from ExtractionRule you can right click ExtractionRule and have VS implement a skeleton of the base class for you. Basically, you'll just want to extract whatever you want from the page in the Extract method and add it to the content using e.Context.Add(this.ContextParameterName, *your variable*).
As far as sharing data between multiple web test iterations, you'll need to use a static member variable or a singleton class to store that data. You're correct that the web text context is designed for use within a single web test iteration.
Josh