Session Template Packages

Document created by Chris Sommerstad Employee on Jul 21, 2017Last modified by B-F-F08DRX on Sep 25, 2017
Version 3Show Document
  • View in full screen mode

A session template can be created from a message response's selected text using the Session Template wizard from within the Clip Editor. A test clip can also be selected from the Test Clips list and the string to search can then be specified from within the Session Templates wizard.


The Session Template Package wizard can be launched from the Test Clips list by selecting a test clip and then right clicking to select the Launch Session Template Package Wizard command. Existing session templates or packages can be applied here using the Apply a Session Template or Package command.

The Session Template Package Wizard can also be launched from the Convert Recording to Test Clip wizard, Next Steps page for a newly converted test clip by clicking Go to the Session Template Package Wizard. When you do so, the test clip is first opened in the Clip Editor, and then the wizard launches.

Once created, both session templates and packages can be viewed from the new Central > Session Templates node.

Additionally, the Clip Editor now includes a Session Template drop-down button that exposes both these commands, as well as the Launch Session Template Wizard. This third command can be launched with or without a selection in the lower panel of the Clip Editor.

Creating a Session Template Package

Session Template Packages can be created from either the Test Clips list or if the test clip is open, click the Session Templates button.

  1. Navigate to Central > Test Clips and select the test clip to parameterize.
  2. Right-click and choose Launch Session Template Package Wizard.


The Session Template Package wizard appears.

The Include and Exclude sections are used to define or delimit the scan. By default, most possible nodes in the recorded responses (in the test clip) are included.

Note: While this wizard runs, CloudTest maintains a draft of the original test clip. If the template is applied, the original test clip is then renamed with the date/time appended to it and the parameterized clip keeps the original name.



    1. Optionally, set custom scan options by checking or unchecking boxes in the Include or Exclude sections. The default scan covers most test clips, while in some frameworks—such as in REST APIs—custom settings may work best. In the Exclude section, enter or delete Names and Values that correspond to an option.

Note: Session templates are created for selected XPath or SubString items, but are not created when the extraction method is changed to new script or existing script.

Include Options

Checked items in this section are included in the test clip scan. 
The following Include options are presented:

  • Headers

Keep this checked to include HTTP headers from the recorded response in the scan of this test clip.

  • Envelope

Keep this checked to scan envelope nodes and attributes (SOAP, REST, etc.).

  • POST Data

Keep this checked to scan POST data associated with this test clip.

  • Query String Params

Keep this checked to scan Query String.

  • Use custom delimiters

Check this box and enter one or more comma-delimited custom delimiters to further delimit the fields POST Data, Query String Params, and Location (and not Entire URL, REST, Envelope, or Headers).

For example, if the user enters the following comma-delimited phrase: ;,:

Then, CloudTest will split the POST Data, Query String Params, and Location on both semi-colon and colon while searching for name/value pairs such as: 123;456;789

If the custom delimiter is: ;

Then, arg1=123, arg2=456, and arg3=789.

  • Location

When Location is checked, either or both of the following two options can also be applied.

  • Entire URL

When including URLs, use the Exclude Names box and entry field on the right to delimit the scan by excluding those fields.

  • REST

REST parameters are excluded (e.g. unchecked) by default. With REST checked, use the Values box on the right to further delimit a scan for REST parameters. Alternately, check “Use a custom delimiter” to introduce a custom delimiter from a given environment. 

Exclude Options

The exclude names and values specified here are skipped during the scan for every Include type on the left. The following Exclude options are presented:

  • Values shorter than x characters

This option is checked and set to 2 characters by default.

  • Names

This option is checked and the listed HTTP header names are excluded by default. These options (along with the URLs field) formerly comprised the Show Advanced section.

  • Values

This option is checked and the listed parameter values are excluded by default.


  1. Once ready, click Scan Clip.

The Scan Clip button becomes inactive and the scan begins. After the clip is scanned, the scan button automatically becomes re-enabled if the Include or Exclude options are changed.

Scan progress is indicated by the green progress bar. Rows begin to appear as the scan progresses.

Additionally, the Working icon appears on the right edge of the Progress bar and to the left of the Scan Clip button.

Once the scan is complete, the green checkmark appears and the table below is populated with name/value pairs. Some rows may appear before the scan completes. Rows whose names have values for suggested replacement are checked.

The scan results are presented in the following columns:

    • Name

The wizard assigns this name for use by CloudTest. This name is based on the Property Name found in column 5 and is used to refer to this pair in the session template package and in the Central > Session Templates list.

    • Value

This value corresponds to the named location or action. For example, the value for a location is a relative URL.

    • Found in Response

This is the test clip component that contains the message response in which the name/value pair is first found. For example, the pair may be first recorded in an HTTP response.

    • Used in Request(s)

This is the test clip component in which the name/value pair is first used by the test clip. For example, a location or property that is found in Message2 may not be used until a subsequent message. 

Any additional occurrences of the pair beyond the first are indicated by count in parentheses. For example, (+4).

    • Property Name

The name of the property specified by responses from the target site. This is distinct from the CloudTest-assigned name in column 1 although the value may be the same.

    • Value Retrieval Method

Each row has a Value Retrieval Method and an Edit button. The possible method types are:

  • SubString
  • XPath
  • New Script
  • Existing Script



    1. Review the scan results. Examine the suggested checked values to replace, as well as any unchecked items of interest.

Check the box for any row to add it to the package as is, or click its Edit button to make changes via the selected value retrieval method. 
Note: For edited items, the row is checked automatically when changes are made via the XPath Editor or SubString Parser.

    1. Optionally, click the Edit icon for a row to view or change details for the SubString or to review or edit the XPath detected by the scan.

Refer to Editing an XPath, Parsing a SubString, Creating a New Script, or Use an Existing Script below for additional instructions for either method.


Note that the Session Template Package Wizard’s Scan Clip function returns results that can be expanded to show all prior messages in the scanned test clip that contain that same value. The user can then select the most relevant value from among those expanded. The original message is displayed as the parent row, with only one level of nesting for all the other messages.

To expand the row, click its corresponding arrow.

Once expanded, the children are all displayed in one level. The expanded row shows the same value selected that was already selected before expansion, in which case that value appears with its radio button selected. This level contains all of the other messages with this value. A radio button is displayed for each possible selection. The child row is where a given value originates. It allows the user to chose to extract not from the first response we find the value in, but from previous responses.

  1. Give the session template package a name, and optionally, specify a folder location and a description for it.

  1. Once the settings for each checked row are satisfactory, click Apply. The progress bar once again indicates the status, this time applying the specified values.

When you click Apply, all checked rows are sent to the server. Then, working on the draft of the test clip, the Session Template Package wizard creates clip-level custom properties, and adds the corresponding message-level property paths that utilize them, as well as defining Property Sets.

Note: In the Session Templates Package Wizard any Session Templates that use the Existing Script or New Script options will appear with their text in the list with strike-through on it, to indicate that the time will not be saved as one of the Session Templates in the package.

  1. Click OK to complete the process. Clicking OK renames the original clip and promotes the draft to the original clipname and then exits the wizard.


Parsing a SubString

    1. Locate the row of the name/value pair and check its row box or select SubString as the value retrieval method (in some cases it may already be selected). The SubString Parser box appears.

If the box doesn't appear, click the Edit button (with SubString selected as the Value Retrieval Method for the row).

The SubString Parser box appears. The recorded value is highlighted in orange. If the string is very long the box will scroll right to display as much of it as possible.

    1. To extract this string, specify Leading Text or Trailing Text to delimit it by first selecting the given text to use and then clicking the Insert Selected button for that value.
    2. Specify the Leading Text before the string by selecting it and clicking Insert Selected on that row. This will include it in the string search.
    3. Specify the Trailing Text after the string by selecting it to include and clicking Insert Selected on that row. Using Trailing Text will further delimit the sub-string search.
    4. In the Test Result row, click the Test button to test the current selections. If the expression is not successful “No match” is posted in the Test Result field. If this occurs try providing additional criteria from among the below:


      • Value Length – Specify the value length to search.
      • End of Text – Specify the EOT (or accept the default).
      • Test Result – Click the Test button to test the current selections. If the expression is not successful “No match” is posted in the Test Result field.


In the shot on the right the Test Result field shows the __VIEWSTATE value has been successfully extracted.

Creating a Regular Expression Using the SubString Parser

The SubString Parser provides the unique ability to build regular expressions based on selected text from the message response text shown above. Use the following steps to create a regular expression.

Note: In CloudTest, when you are entering a Regular Expression for a Session Template, to Include/Exclude resources in a page, or for a PropSet in the Message Editor portion of the Clip Editor, you are entering a Java regular expression. Whereas, when you use regular expressions within a script (via the RegExp object or the /pattern/ notation), you are using a JavaScript regular expression. The two are not interchangeable, so you can’t copy expressions from one to the other. 

The Regular Expression section includes the following fields:

  • Expression – This field displays the regular expression that is being built here.
  • Insert Non-Fixed – Highlight and click Insert Non-Fixed for all non-fixed characters in both Leading Text and Trailing Text.
  1. Optionally, check Use Regular Expression. Checking this box displays additional settings used to define a regular expression using both Leading Text and Trailing Text.
  2. Select text before or after a highlighted value. Highlights are in orange text.

  1. Click OK to accept your settings or Cancel to abandon the SubString changes. Clicking OK here automatically checks the edited row for inclusion in this session template package.


In the example on the right, an __EVENTVALIDATION field was found in a scan, and then the Edit button for the method, SubString, was clicked. The value of this field is quite long.

  1. We used the horizontal scroll bar to locate where the highlighted string began.

  1. Then, as above, we selected text before the orange text, and then clicked Insert Selected for the Leading Text field. The Leading Text field was populated.

    1. Then we did the same for the text after the orange text and then clicked Insert Selected for the Trailing Text field.

TIP: In cases where variable, or non fixed, text is part of a text string that has been inserted into either the Leading Text or Trailing Text fields, that text can be replaced in the expression below by first selecting it, and then clicking Insert Non-Fixed to the right of the Expression field.

For example, if the text string, value (on the right), is “non-fixed” (e.g. changes from session to session), select it and then click the Insert Non-Fixed button.

After Insert Non-Fixed was clicked, the Expression field string, value, reflected this change (on the right).

  1. After we had a successful result, we checked Use Regular Expression to reveal the regular expression equivalent for the result.

Note: If Use Regular Expression is checked at the time the Insert buttons are used, the Expression field is populated at that time.

  1. Once the expression below has been built, test it by clicking the Test button. If the expression is successful, the text between trailing and leading selections above is captured (e.g. the captured text is the same as the orange highlighted text from above) in the Test Result field (the text is not highlighted a second time).

Editing an XPath

An XPath can be reviewed, revised, and tested using the XPath Editor.

    1. When XPath is selected and Edit is clicked, the XPath Editor box appears. This box has two text fields. The top field shows the row item in orange (as in the SubString Parser). The bottom field shows an editable XPath.

XPath values can be manually edited; however, care should be taken when doing so as invalid code will break the test clip.

  1. After making any changes, click the Test button to ensure the XPath is valid. A valid path will capture the data within the given XPath in the Test Result field (as shown below).
  2. Click OK or Cancel to abandon XPath changes.

Creating a New Script

    1. When New Script is selected and Edit is clicked, the New Script and Value Location Definition box appears.

Use this box to specify parameters for generating a script to replace the specified value. This page does not appear when using other wizard options.

  1. Give the new script a name.
  2. Check Save as a linked script to insert this script into the test clip. A linked script will be inserted after the relevant test clip component(s), which must have local scope. Uncheck the Save as a link script box to save the script without adding it to this test clip.
  3. Response Content from the prior step is shown with a default parameter selected. Select text in the Response Content field and then click Insert Selected for any of the following: Leading Text, Trailing Text, Value Length or End of Text.
  4. Click Generate Script to generate the script. The script code is posted to the script field based on the selection(s). If alternate values were selected above after Generate Script was clicked, click the button a second time.
  5. Click OK or Cancel to abandon the new script.

Use an Existing Script

  1. When Existing Script is selected and Edit is clicked, the Script Browser box appears.
  2. Locate and select the script to use in the list.
  3. Click OK to use the selection or Cancel to abandon this change.