Dela via


Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test

In this walkthrough, you will add validation and extraction rules to a Web performance test and verify that they work correctly.

Validation rules help verify that a Web application is working correctly by validating that text, tags, or attributes exist on the page that is returned by a Web request.

Extraction rules are similar to validation rules, but instead of just verifying data, they will extract the data and store the result in the Web performance test context. For more information, see Using Validation and Extraction Rules in Web Performance Tests.

In this walkthrough, you will perform the following tasks:

  • Add a validation rule to a Web performance test.

  • Verify the validation rule results.

  • Add an extraction rule to a Web performance test.

  • Verify the extraction rule results.

Prerequisites

To complete this walkthrough, you need the following:

Preparing for the Walkthrough

To prepare for the walkthrough

  1. Open the Web application that you created in Walkthrough: Creating a Simple Web Application.

  2. Press CTRL+F5 to run the Web application in the browser. You should see the first page. Close the browser.

    Note

    This starts the ASP.NET Development Server that runs the Web application your Web performance test will test. You will see the ASP.NET Development Server icon in the notification area.

  3. Open the Web application you created in Walkthrough: Recording and Running a Web Performance Test.

  4. In Solution Explorer, double-click ColorWebTest.webtest. The Web Performance Test Editor appears and the list of Web requests is displayed.

Adding a Validation Rule to a Web Performance Test

In this Web performance test, you selected the Red option and clicked submit. Now you will add a validation rule to verify that you actually visit the page Red.aspx.

To add a validation rule to the Web performance test

  1. In the Web Performance Test Editor, find the request that redirects to the page Red.aspx. This should be the second node in the request list.

    Important

    The Web application uses a redirect to move from the page Default.aspx to the page Red.aspx. In the Web Performance Test Editor, the request list will show Default.aspx, not Red.aspx, for the request you are trying to find. To find the correct request, expand the request node, expand the Form Post Parameters folder, and confirm that there is an entry RadioButtonList=Red.

  2. Right-click the Web request and choose Add Validation Rule.

    The Add Validation Rule dialog box is displayed.

  3. In the Select a rule pane, choose Find Text.

  4. In the Properties pane, set the Find Text property to Red, and set the Pass If Text Found property to True.

  5. Click OK.

  6. On the File menu click Save ColorWebTest.webtest to save the Web performance test.

Verifying Validation Rule Results

To verify the validation rule results

  1. In the Web Performance Test Editor, click Run to start your Web performance test.

    The Web Performance Test Results Viewer is displayed.

  2. In the top pane of the Web Performance Test Results Viewer, click the request for the page Red.aspx.

  3. In the bottom pane of the Web Performance Test Results Viewer, click the Details tab. The Validation and Extraction Rules grid is displayed with the results of the validation rule.

Adding an Extraction Rule to a Web Performance Test

In this Web performance test, you selected the Blue option and clicked submit. Next you will add an extraction rule get the style of the Label on the page Blue.aspx.

To add an extraction rule to the Web performance test

  1. In the Web Performance Test Editor, find the request that redirects to the page Blue.aspx. This should be the fourth node in the request list.

    Important

    The Web application uses a redirect to move from the page Default.aspx to the page Blue.aspx. In the Web Performance Test Editor, the request list will show Default.aspx, not Blue.aspx, for the request you are trying to find. To find the correct request, expand the request node, expand the Form Post Parameters folder, and confirm that there is an entry RadioButtonList=Blue.

  2. Right-click the Web request and then choose Add Extraction Rule.

    The Add Extraction Rule dialog box is displayed.

  3. In the Select a rule pane, choose Extract Attribute Value.

  4. In the Properties pane, set the following properties:

    Property

    Value

    Context Parameter Name

    ExtractionTest

    Tag Name

    span

    Attribute Name

    style

    Match Attribute Value

    Color:Blue

  5. Click OK.

  6. Choose File and then Save to save the Web performance test.

Verifying Extraction Rule Results

To verify the extraction rule results

  1. In the Web Performance Test Editor, click Run to start your Web performance test.

    The Web Performance Test Results Viewer is displayed.

  2. In the top pane of the Web Performance Test Results Viewer, click the request for the page Blue.aspx.

  3. In the bottom pane of the Web Performance Test Results Viewer, click the Details tab.

    The Validation and Extraction Rules grid is displayed with an entry for the extraction rule you just added.

  4. Click the Context tab.

    A grid of names and values is displayed. The last entry will be the value extracted by the rule, color:Blue;.

Next Steps

In this walkthrough you added validation and extraction rules to a Web performance test.

To add data binding to your Web performance test, see Walkthrough: Adding Data Binding to a Web Performance Test. Finally, to convert your Web Performance Test to a coded Web performance test, see Walkthrough: Creating a Coded Web Performance Test.

See Also

Tasks

Walkthrough: Creating a Simple Web Application

Walkthrough: Recording and Running a Web Performance Test

Walkthrough: Adding Data Binding to a Web Performance Test

Walkthrough: Creating a Coded Web Performance Test

Concepts

Using Validation and Extraction Rules in Web Performance Tests