How to: Add a Validation Rule to a Web Test

Validation rules help verify that a Web application is working correctly by validating the existence of text, tags, or attributes on the page returned by a Web request. Validation rules can also verify the amount of time it takes a request to finish, and the existence of form fields and their values. For more information, see About Validation Rules.

You add validation rules to Web tests in the Web Test Editor. For more information about how to edit a Web test, see How to: Edit an Existing Web Test.

Procedure

To add a validation rule to a Web test

  1. Open a Web test.

    For more information about how to create a Web test, see Creating a Web Test.

  2. In the Web Test Editor, select the request to which you want to add a validation rule.

  3. Right-click the request and select Add Validation Rule.

    The Add Validation Rule dialog box is displayed.

  4. In the Add Validation Rule dialog box, select a rule to configure, for example select Find Text. Find Text is a validation rule that looks for a specific string in the HTTP response to your request. For information about other predefined validation rules, see About Validation Rules.

  5. For the Find Text property, type a string that you expect to appear in the response body when the test runs.

  6. Set the Pass If Text Found property to True.

  7. Click OK to close the Add Validation Rule dialog box.

  8. On the File menu click Save to save the Web test.

  9. In the Web Test Editor, click Run to start your Web test.

    The Web Test Viewer is displayed.

  10. In the top pane of the Web Test Viewer, click the request to which you added the validation rule.

  11. In the bottom pane of the Web Test Viewer, click the Details tab.

    The Validation and Extraction Rules grid is displayed with an entry for the validation rule you just added. Verify that the validation rule worked as expected.

See Also

Tasks

How to: Create a Custom Validation Rule

Walkthrough: Adding Validation and Extraction Rules to a Web Test

How to: Edit an Existing Web Test

Concepts

About Validation Rules

Creating a Web Test