Share via


How to: Use Context Parameters in a Web Performance Test

This topic applies to:

Visual Studio Ultimate

Visual Studio Premium

Visual Studio Professional 

Visual Studio Express

Topic applies Topic does not apply Topic does not apply Topic does not apply

You can create context parameters to use in a Web performance test by using the Web Performance Test Editor. Context parameters let you parameterize a string in a Web performance test. For example, in the two procedures that follow, a context parameter is created for a Web site. The context parameter lets the test be changed quickly from one site to another.

You may develop your Web tests in one test environment, and then have to re-run them against another environment. A common practice is to have test, preproduction, and production environments.

In Web tests, you can parameterize the Web Server to put the server part of the URL in a context parameter.

To add a context parameter to a Web performance test

  1. Open a Web performance test.

    The Web Performance Test Editor opens and the request tree for the Web performance test is displayed.

  2. In the request tree, either right-click the Web performance test node (root node).

    -or-

    Right-click the Context Parameters node.

  3. Click Add Context Parameter.

    A new parameter is added and selected under the Context Parameters node.

  4. On the View menu, click Properties Window.

    The Properties Window is displayed and the properties for the new context parameter are displayed.

  5. In the Name properties text box, type the name that you want to use for the new context property (for example, Alternate test site).

  6. In the Value properties text box, type the value that you want to use for the new context property (for example, AlternateSite).

    Next, you can conduct the steps in the following procedure to use the new context parameter in a Web performance site

To use a context parameter in a Web performance test

  1. Review the steps in the previous procedure.

  2. To apply the context parameter, select a node in the request tree that you want to parameterize. For example, you might want to use a parameter for a Web request.

  3. In the Properties Window, apply the context node to a property that you want to parameterize. For example, select the text box for the URL property for a Web request and update the text. For example, replace the existing property value of {{WebServerName}}//SiteName with {{WebServerName}}//{{AlternateSite}}.

    -or-

  4. Use Replace in Request to search for a string to parameterize. You can use Replace in Request to quickly parameterize all Web requests in a Web performance test.

  5. In the request tree, right-click any node and then click Find and Replace in Request.

    The Find and Replace in Request dialog box is displayed.

    Note

    You cannot use CTRL+F for find and replace functionality in a Web performance test. CTRL+F opens the Visual Studio Find and Replace dialog box. In a Web performance test, you must use the Find and Replace in Request in the shortcut menu of a node.

  6. In the Find what text box, type the text that you want to find. For example, SiteName.

  7. In the Replace with text box, type the text that you want to use to replace the text that you entered in the Find what text box. For example, {{AlternateSite}}.

  8. Click Find Next to locate the first occurrence of the text that you entered in the Find what text box in a Web request.

  9. If you determine that you want to replace the occurrence, click Replace; otherwise, click Find Next to search for the next occurrence.

  10. Repeat steps 9 and 10 until you find all the occurrences in all the Web requests.

    -or-

  11. Click Replace All to parameterize all occurrences in all Web requests of the text that you entered in the Find what text box by using the text that you entered in the Replace with text box.

See Also

Tasks

How to: Use Find and Replace in a Web Performance Test

Concepts

About Threshold Rules in Load Tests

Other Resources

Customizing Web Performance Test Recordings Using Web Performance Test Editor