Checking Whether a Server Response Contains Specific Text

Applies to LoadComplete 4.97, last modified on May 20, 2019

Often, to verify whether the tested server processes a simulated request correctly, you need to check the response contents (see Verifying Server Responses). A typical task is to verify whether a response contains specific data. The way you check this depends on the web application and protocol it uses.

Checking a Textual Response

If the web application returns a response in the textual format, then to automate verification, you need to:

  1. Create a data selector that will extract the needed data from a server response and store it to a variable.

  2. Define a validation rule that will verify that the variable contains the desired data.

Below is a step-by-step description:

  1. Open your user scenario for editing. To do this, right-click the scenario in the Project Explorer and select Edit from the context menu, or simply double-click the scenario in the Project Explorer.

  2. In the Scenario editor, find the server response you would like to check.

  3. Open the response’s Data Selectors tab.

  4. Create a data selector that will extract the desired data from a response:

    • Right-click anywhere within the Data Selector tabbed page and then click Create data selector with wizard. LoadComplete will open the Create Data Selector wizard that assists you in creating data selectors.

    • In the wizard, choose Retrieve text and specify the text you want to check.

    • Verify that the created regular expression matches the appropriate data and close the wizard.

    • LoadComplete will add the created data selector to the selectors list.

  5. By default, when you create a data selector, LoadComplete automatically create a new variable that will store the extracted data. If needed, specify another variable in the Variable column.

Note: If the data you want to check contains URL-encoded characters (like %20 or %2B) or HTML entities (like &amp or &gt), LoadComplete may display a message suggesting that you decode these symbols and replace them with regular characters.

If you choose Yes, LoadComplete will automatically select the appropriate conversion rule for your data selector and will replace the special symbols with regular characters before saving the data to a variable. This frees you from having to specify special characters in a baseline value when creating a validation rule.

However, to avoid possible issues, we recommend that you choose No (or choose None in the Convert column) and specify a baseline value that contains the same URL-encoded characters and HTML entries which the extracted data contains.

After you create the data selector, you define a validation rule:

  1. Switch to the Validators tab of the Response page.

  2. Right-click within the tab and then click New Item. This will add a new rule.

  3. In the Variable column, select the variable that stores the extracted data.

    In the Variable or Value column, enter the baseline value against which LoadComplete will compare the extracted data.


    • You can copy the baseline value from the Request Body tab.

    • If you did not modify conversion settings when creating the data selector (see above), make sure the text you specified in the Variable column includes URL-encoded characters or HTML entities, if the extracted data includes them.

  4. In the Operation column, select a validation condition: Equals, Does not equal, Contains or Does not contain.

  5. Select File > Save from LoadComplete’s main menu to save the changes.

Checking Responses of Rich Internet Applications

Rich Internet Applications use protocols that typically pass packed data.

If you are testing a Rich Internet Application, you cannot create a validation rule that will search within the entire response. You can create only rules that will validate the contents of individual parameters.

For complete information on this, see Creating Validation Rules.

See Also

Typical Use Cases
About Validating Response Contents
Creating Validation Rules
Regular Expressions Syntax

Highlight search results