Working with Session Variables


Dynamic data on HTML pages is usually represented in the form of:

part of URL path that changes each time you access a web page, or
a field (sometimes hidden) recorded during a form submission.

Below are 2 typical examples of using the dynamic data on HTML pages.

Example 1.

Suppose you need to automate a simple scenario of navigating through a certain site using respective HTTP requests:

  1. User registration:

    http://myserver/register?User=Alex&Pass=qwerty

  2. After registration, the user is redirected to the main category which displays links to all resources of the site. At this stage, the SessionID session variable is generated. The user selects the Main category by clicking the respective link:

    http://myserver/view?SessionID=FCHHAB02DF&Category=main

  3. The user selects a link to a particular resource:

    http://myserver/view?SessionID=FCHHAB02DF&Category=main&Item=67
During recording, WAPT Pro records this sequence of HTTP requests, but the static value of SessionID would not be used to play this sequence back during test run. After sending the second request an error will occur. The reason is that we try to use the old value of SessionID.

Example 2.

When some user submits a form on your site, a unique number is sent to the server together with all information entered by the user. The number is kept in a hidden field of HTML code. It will be different in a new browser session. When you run the test, web server will be unable to recognize that number.

These problems are successfully resolved in WAPT Pro by the usage of variables in recorded test scenario. In both examples, you can define variables and replace the dynamic data with them.

There are two main methods of incorporating the session variables into site pages:
  1. To incorporate session variables into URL path;
  2. To use a request parameter to transmit a session variable.
WAPT Pro supports both methods:
  1. Using functions URL from Form and URL from link;
  2. Using functions Hidden and Parameter from URL.
The Search parameter function can be used in both cases.

Note that functions like Parameter from URL or Hidden which obtain values from the actual server response are calculated using the following as an input:

HTML code of the PREVIOUS page when the function is used for calculation of request PARAMETER value, or
HTML code of the CURRENT page when the function is used for defining a VARIABLE.

How to define a formula for calculation of variable


You can use variables to calculate parameters and URL paths. To define a variable, you can use functions that parse the actual HTML code of response at run-time. The list of variables is displayed on the Response processing tab of request properties:




Add..: Opens the Edit Variable dialog where you can create a new variable and select a function for its calculation. Note that created variable will be available only in subsequent requests.
Remove: Removes selected variable from the list.
Edit..: Opens the Edit Variable dialog where you can edit variable name and the function for its calculation.


Name: Here you can change variable name.
Formula: Here you can view the defined formula for calculation of the current variable. This field is accessible only for viewing.
Functions: The list of functions for calculation of the current variable is displayed in this field. You can define several functions for the same variable. Results of those functions will be concatenated to form more complicated values.

Add..: Opens the Edit Function dialog where you can select a function for calculation of the current variable.
Remove: Removes selected function from the list. (That function will be deleted only from the list of functions for calculation of the current variable.)
Edit..: Opens the Edit Function dialog where you can edit selected function or choose another function.
Move Up: Moves selected function one step up in the list (if you defined several functions for the same variable).
Move Down: Moves selected function one step down in the list.

Here you can read the detailed description of WAPT Pro functions that can be used for calculation of the values of session variables to form the correct URL during run-time.

Next page