Export (0) Print
Expand All

Using Validation and Extraction Rules in Web Performance Tests

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 time that it takes a request to finish, and the existence of form fields and their values.

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.

This topic describes how to create and use validation and extraction rules in Web performance tests.

Requirements

  • Visual Studio Ultimate

In this topic:

Visual Studio Ultimate includes the following predefined validation rules:

Validation Rule Type

Description

Find Text

Verifies the existence of specified text in the response. For more information about using the find text validation rule, see Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test.

Form Field

Verifies the existence of a form field that has a specified name and value.

Maximum Request Time

Verifies that the request finishes within a specified amount of time.

Required Attribute Value

Verifies the existence of a specified HTML tag that contains an attribute that has a specified value.

Required Tag

Verifies the existence of a specified HTML tag in the response.

Response Time Goal

Validates that the response time for the request is less than or equal to the response time goal as specified on the request. Response time goals of zero will be ignored.

Response URL

Validates that the response URL, after redirects are followed, is the same as the recorded response URL. QueryString parameters are ignored.

Selected Option

[Visual Studio 2012.1]

Validates that the specified option in the HTML 'select' tag is selected.

SharePoint - Find Multiple Text Occurrences

[Visual Studio 2012.1]

Similar to the Find Text validation rule but allows you to specify more than a single text string.

Note Note

This validation rule requires Visual Studio Ultimate 2012.1 or later.

SharePoint - Response URL

Similar to the Response URL validation rule but allows you to turn it off for specific requests and specify custom terminators.

Note Note

This validation rule requires Visual Studio Ultimate 2012.1 or later.

Tag Inner Text

Validates that the specified expected inner text exists within the specified HTML tag.

For example, you can validate that specific inner text exist in a list box where the option text is stored in inner text rather than an attribute:

<select name="myListBox">
        <option>Car</option>
        <option>Train</option>
        <option selected="selected">Ship</option>
        <option>Airplane</option>
    </select>
    </form>

In this case, if you wanted to verify that "Airplane" exists in myListBox, you would set the following properties for the validation rule:

  • Expected Inner Text to Airplane.

  • Tag Name to option.

Visual Studio Ultimate provides predefined validation rules in the form of classes in the Microsoft.VisualStudio.TestTools.WebTesting.Rules namespace. However, you can create your own custom validation rules by deriving from the ValidationRule class. For more information, see How to: Create a Custom Validation Rule for a Web Performance Test.

Execution of validation rules has an impact on performance in load testing. To reduce the performance impact, use the Validation Level of a request to control which validation rules are used in a specific load test. You can set the validation level of each rule to Low, Medium, or High. Typically, the higher you set the validation level, the slower your test will run.

Setting the Validation Level of a rule in a request determines when that validation rule is used in a load test. For example, setting it to High means that the rule is executed only when the load test validation level is set to high.

Load Test Validation level

Description of Request settings used

Low

Invoke only rules with a setting of Low

Medium

Invoke rules with a setting of Low and Medium

High

Invoke all rules - Low, Medium, and High

The ability to set the rule levels in both the Web performance test request and the load test setting gives you flexibility in your testing. Setting a load test setting to Low executes the fewest rules and can be used for heavy load test and stress runs. Setting a load test setting to High executes the most rules and should be used when validation is more important than maximum throughput.

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.

Validation rules are similar to extraction rules, but instead of extracting data, they validate the existence of data.

Visual Studio Ultimate includes the following predefined extraction rules:

Extraction Rule Type

Description

Extract Attribute Value

Extract the value of an attribute from a specified HTML tag. For more information about using the extract attribute value rule, see Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test.

Extract Form Field

Extract the value of a specified form field in the response.

Extract Hidden Fields

Extract all hidden fields from the response.

Extract HTTP Header

Extract the value of an HTTP header.

Extract Regular Expression

Extract text from the response matching a regular expression.

Extract Text

Extract text from the response.

Selected Option

Extract the selected text in a list or combo box.

Tag Inner Text

Extracts the inner text from the specified HTML tag.

Visual Studio Ultimate 2012 with Visual Studio 2012.1 or later includes the following predefined extraction rules for SharePoint apps:

Extraction Rule Type

Description

SharePoint - Extract Form Field

Extract the value of a specified SharePoint text box or hidden form field in the response and place it into the test context.

SharePoint - Extract GUID

Extract SharePoint GUID from the response and place it into the test context.

SharePoint - Extract GUID Form Field

Extract the value of the form field name, which contains a GUID, in the following format: BeginningOfName_mg_EmbeddedGUID_RemainderOfName. For example:

[ctl00_mg_69f4ec15_04da_449b_82ee_d6cdd46f8518_ctl00_ctl05_ctl05_ctl00_ctl00_ctl04_ctl00_ctl00_UserField]

SharePoint - Extract Selected Option

Extract a value from a SharePoint ComboBox DropDown list in the response.

SharePoint - Extract Text On Key

Extract the value of a specified string, based on a key that is provided in the response, and place it into the test context.

SharePoint - Extract WebParts ListView Values

Extract all values from the script portion of webpart list view in the response using the list title as the search criteria.

SharePoint – Find Calendar Date

Extracts a date value in the response on a SharePoint calendar.

SharePoint – Find Calendar Item

Extracts the ID value of a specified event in the response on a SharePoint calendar list.

SharePoint – Find Document Item

Extracts the ID value of a specified document in the response from a SharePoint document list.

SharePoint – Find Hrefs

Extracts href references in the response that matches the search criteria.

SharePoint – Find List Item

Extracts the ID value of a specified list Item in the response.

Visual Studio Ultimate provides predefined extraction rules in the form of classes in the Microsoft.VisualStudio.TestTools.WebTesting.Rules namespace. However, you can create your own custom extraction rules by deriving from the ExtractionRule class. For more information, see How to: Create a Custom Extraction Rule for a Web Performance Test.

Tasks

Associated Topics

Adding validation rules in a Web performance test: Add and configure a validation rules in your Web performance test to 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 time it takes a request to finish, and the existence of form fields and their values. Validation rules can be also be specifically used on inner text and on select targets.

You can also add validation rules to Web performance tests at the test-level which fires on every request in the test.

Adding extraction rules in your Web performance test: Add and configure an extraction rules to 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.

Creating your own custom validation and extraction rules: In addition to using the validation and extraction rules that are predefined in Microsoft Visual Studio Ultimate, you can create your own rules by deriving them from either the ValidationRule or the ExtractionRule base classes. After you create a custom validation or extraction rule, you can add it to a Web performance test request.

Show:
© 2014 Microsoft