How to: Add an Extraction Rule to a Web Performance Test
Extraction rules help verify that a Web application is working correctly by extracting data from the responses to Web requests. Extraction rules store results in the test context as name value pairs. Extraction rules can extract form fields, text, attributes, headers, regular expressions, and hidden fields. For more information, see Using Validation and Extraction Rules in Web Performance Tests.
You add extraction rules to Web performance tests in the Web Performance Test Editor. For more information about opening and editing a Web performance test, see How to: Edit an Existing Web Performance Test Using the Web Performance Test Editor.
- Visual Studio Ultimate
To add an extraction rule to a Web performance test
Open a Web performance test.
For more information about how to create a Web performance test, see Creating and Editing Web Performance Tests.
In the Web Performance Test Editor, select the request to which you want to add the extraction rule.
Right-click the request and select Add Extraction Rule.
The Add Extraction Rule dialog box is displayed.
In the Add Extraction Rule dialog box, in the Select a rule pane, select a rule to configure. For example, select Extract Attribute Value. For information about other predefined extraction rules, see Using Validation and Extraction Rules in Web Performance Tests.
In the Properties for selected rule pane, set the Context Parameter Name property to a descriptive name such as FirstLink. When the extraction rule runs, a context variable named FirstLink is created that contains the extracted string.
Set the Attribute Name property to href and the TagName property to a.
The HTML format of what we are trying to extract in this example is <a href=http://www.contoso.com>, where a is referred to as the tag and href is the attribute of interest.
Choose OK to close the Add Extraction Rule dialog box.
On the File menu choose Save to save the Web performance test.
In the Web Performance Test Editor, choose Run to start your Web performance test.
The Web Performance Test Results Viewer is displayed.
In the top pane of the Web Performance Test Results Viewer, choose the request to which you added the validation rule.
In the bottom pane of the Web Performance Test Results Viewer, choose the Details tab.
The Validation and Extraction Rules grid is displayed with an entry for the extraction rule you just added.
Choose the Context tab.
A grid of names and values is displayed. The last entry will be the FirstLink variable and its value. The value should match the first <a href> on the requested page. You can verify this by viewing the requested page in a browser, viewing the source of the page, and searching for the first href.