WAPT Pro Functions


Below is the detailed description of functions which can be used for dynamic calculation of parameter values and variables.

  1. Static text
  2. Variable - $Var
  3. Ordered list - $LOrder
  4. Random from list - $LRand
  5. Numeric random - $NRand
  6. Alphanumeric random - $ARand
  7. User number - $UserID
  8. Sequence - $Seq
  9. JavaScript - $JavaScript
  10. Comma Separated Values - $CSV
  11. Cookie - $Cookie
  12. XPath - $XPath
  13. Hidden - $Hidden
  14. Search parameter - $Search
        • As $Search() command
  15. Header - $Header
  16. Parameter from URL - $UrlParam
  17. URL from link - $HRef
  18. URL from Form - $Action

You can test the work of any function by clicking the Test button in the dialog with the function properties. You will see the function value calculated using the recorded server response. If the function is executed with an error, you will additionally see the corresponding error message. This button is disabled for functions working with the server response in streaming and WebSocket requests.

Static text


Returns a specified text - one or several strings.

You can insert variables $Var(var-name) inside the entered text. Enter the $ sign and you will see a prompt with the list of available variables. Select a desired variable in the list to insert it into the text. After execution of this function, the text will contain the calculated values of inserted variables.

Example:

Variable - $Var


Returns the value of specified variable. Variables will help you handle different user-dependent parameters like session IDs or view states. Variables can be defined using any function and redefined later if necessary.

Note that functions which obtain values from the actual server response (hidden form values and others) use the HTML code of the CURRENT page as an input when they are used for defining a variable.

Syntax: $Var({name})

Example:



Type the name of variable in the Variable name field. While you are typing, you will see a prompt with the list of similar variables (if they exist). You can select the necessary variable there. Or you can click the Select... button and select a variable in the displayed dialog (here you see all variables created on one of the previous pages):



WAPT Pro has several internal variables:

Session_number - the number of current session (starts from 0)
User_number - the number of current user (starts from 0)
Loop-name_iteration - the number of loop iteration (starts from 0)
For each loop that you add to the test sequence, WAPT Pro creates a special variable - the number of iteration. This variable is displayed in the list of variables only for requests inside a loop (Loop operator). If, for example, loop name is Main Loop, variable's name is Main Loop_iteration.

After you add a parameter that uses the function $Var, you can see the following prompt when you move the mouse cursor over that parameter in the list of parameters:



The prompt shows the value of used variable and also on which page it is initialized. If you click the displayed link, you will get to that place where variable is initialized.

Ordered list - $LOrder


Returns the 1-st string from a specified list for the 1-st user/session of current profile, the 2-nd string - for the 2-nd user/session of current profile and so on. When you add this function for some request inside a loop (Loop operator), you will see three available modes: users, sessions and loop iterations. If you choose the loop iteration mode, this function will return the 1-st string from a specified list for the 1-st iteration of the loop, the 2-nd string - for the 2-nd iteration and so on.

Choose a desired mode in the combo-box (Different values for different users/sessions/loop_name iterations). Then specify the list of strings: type one string per line in the text field. Or you can load strings from a file: check the Load strings from a file option and choose the necessary file. In the Use file encoding combo-box you need to specify which encoding should be used to read the data from your file.

The list of records is cycled so that if the number of users/sessions/loop iterations is more than the list length, then the 1-st string will be used after the last one.

$LOrder function supports a multi-string input of data. It means that you can enter some text consisting of several strings as the value of parameter. You should use the combination of symbols \r\n to separate different strings for the same parameter. After you type a desired text, press Enter and specify a value of the next parameter in the next line.

This function can be used to provide each virtual user with the individual user name and password. Note that if you want to use user/password pairs, you need to specify 2 parameters and provide the lists of usernames and passwords separately for each of them.

Syntax:

$LOrder(users,value1,value2,…) for users
$LOrder(sessions,value1,value2,…) for sessions
$LOrder(Loop_name,value1,value2,…) for loop iterations
$LOrder(users/sessions/Loop_name,filename.txt) in case you load strings from a specified file

If you add this function for requests from embedded loops, use different loop names.

Example 1:

$LOrder(users,John,Mike,Bob)

It results in sending the following HTTP requests:

First virtual user:
POST /login.do
username=John&...

Second virtual user:
POST /login.do
username=Mike&...

Third virtual user:
POST /login.do
username=Bob&...


Example 2: multi-string input of data

In this case parameter value for the first virtual user will be equal to:

string1
string2

for the second virtual user:

string3
string4

and for the third:

string5
string6

Random from list - $LRand


Returns a random string from a specified list.

Specify the list of strings: type one string per line in the text field. Or you can load strings from a file: check the Load strings from a file option and choose the necessary file. In the Use file encoding combo-box you need to specify which encoding should be used to read the data from your file.

$LRand function supports a multi-string input of data. It means that you can enter some text consisting of several strings as the value of parameter. You should use the combination of symbols \r\n to separate different strings for the same parameter. After you type a desired text, press Enter and specify a value of the next parameter from the next line.

Syntax: $LRand({file_name}|value1[,{value2},…])

Example 1:

$LRand(test4,bobby,alpha)

It results in sending HTTP requests like these:

http://myserver/view?param=alpha
http://myserver/view?param=test4
http://myserver/view?param=bobby


Example 2: multi-string input of data

As a result, parameter values will be taken from this list at random, for example:
for the first request:

string5
string6

for the second request:

string3
string4

and for the third:

string1
string2

Numeric random - $NRand


Returns the concatenation of prefix string and evenly distributed random number in the specified range.

Syntax: $NRand({prefix},{from},{to})

In other words, it returns a random integer located in the [from,to] range preceded by a {prefix} (if one specified). An integer number will be greater than or equal to the value specified in the "From" field and less than or equal to the value specified in the "To" field.

You can insert variables $Var(var-name) in the "From" and "To" fields. Enter the $ sign and you will see a prompt with the list of available variables. Select a desired variable in the list.

Example:

$NRand(ID,1,20)

Below are sample HTTP requests that could be sent to the server:

http://myserver/view?param=ID5
http://myserver/view?param=ID12
http://myserver/view?param=ID2

Alphanumeric random - $ARand


Returns a random alphanumeric string with the length from a specified range.

Syntax: $ARand({from},{to})

In other words, this function returns a random alphanumeric string with the length located in the [from,to] range (the length will be greater than or equal to the value specified in the "From" field and less than or equal to the value specified in the "To" field.)

You can insert variables $Var(var-name) in the "From" and "To" fields. Enter the $ sign and you will see a prompt with the list of available variables. Select a desired variable in the list.

Example:

$ARand(1,20)

It results in sending HTTP requests like these:

http://myserver/view?param=g
http://myserver/view?param=fndy5lgs5pck
http://myserver/view?param=xfglfgjl4asd098ljk6c

User number - $UserID


Returns the concatenation of 3 parameters: a prefix string, the number of virtual user of the current profile (starts from 0) and postfix string.

For example, this function can be used to provide each virtual user with the individual user name and password.

Syntax: $UserID({prefix},{postfix})

Example:

$UserID(name,)

It results in sending the following HTTP requests:

First virtual user:
POST /login.do
username=name0&...

Second virtual user:
POST /login.do
username=name1&...

Third virtual user:
POST /login.do
username=name2&...

Sequence - $Seq


Returns the sequence of strings that are the concatenation of the prefix string and an integer number with some leading zeros (leading zeros appear if the length of the integer number is less than the value specified in the "Width" field). The integer number is calculated according to formula:

Start + RN + Shift*UN,

where RN is the number of current request execution within the whole test, and UN is the number of current user.

Syntax: $Seq({prefix},{start},{shift},{width})

Example:

$Seq(thread,2,5,2)

The 1-st virtual user will send these HTTP requests to the server:

http://myserver/view?param=thread02
http://myserver/view?param=thread03
http://myserver/view?param=thread04

The 2-nd virtual user will send these HTTP requests:

http://myserver/view?param=thread07
http://myserver/view?param=thread08
http://myserver/view?param=thread09

And the 3-d virtual user will send these HTTP requests:

http://myserver/view?param=thread12
http://myserver/view?param=thread13
http://myserver/view?param=thread14

JavaScript - $JavaScript


WAPT Pro allows the execution of JavaScript within virtual user profiles. You can use JavaScript functions when you define request parameters or variables. Note that if you use JavaScript function, you should first define it in one of files of JavaScript library (JavaScript tab of program settings).

If you wish to define some variable or request parameter as a result of JavaScript function, you should select "JavaScript" as function type and specify function name and function parameters.

Syntax: VarName=$JavaScript(function-name,parameter1-name,parameter2-name,...)

Example:

Suppose you define a variable which is calculated as a result of function "summ" - the sum of 2 variables.

Type: Select "JavaScript" as function type.

Function name: Type the name of some function defined in WAPT Pro JavaScript library.

Function parameters: Here you can specify function parameters. Each parameter can be calculated as a result of some function. Click the Add... button and you will see the same Add Function dialog where you can define a new parameter and a function for its calculation.

JavaScript Library: Click this button and you will see the list of files included in the library. If you select some file in the list, its JavaScript code will be displayed in a new window.




You can add new files to the library. Click JavaScript Library -> Add JavaScript File... button and you will switch to the JavaScript tab of program settings where you can add new files.

When you finish editing the function, click OK to save changes. In the Edit Variable (or Edit Parameter) dialog you will see the formula for calculation of variable (parameter).

So in this example, the variable SessionID will be calculated as:

SessionID=$ARand(1,20)+$NRand(ID,1,20)

Note that any JavaScript error is considered to be session error, so it stops execution of the current session. Calling the log.error method from JavaScript is also considered to be JavaScript error (session error).

Comma Separated Values - $CSV


Using this function, you can load the data from a specified .csv or .txt file. That file should consist of records separated by some delimiter. You can use the following delimiters:

TAB
SPACE
;
,

Select a file and specify the number of column in it. Records of that column will be taken one by one and returned as parameter values. As a result, this function will return the 1-st record of specified column for the 1-st user/session of current profile, the 2-nd record - for the 2-nd user/session and so on.

When you add this function for some request inside a loop (Loop operator), you will see three available modes: users, sessions and loop iterations. If you choose the loop iteration mode, this function will return the 1-st record of a specified column for the 1-st iteration of the loop, the 2-nd record - for the 2-nd iteration and so on.

Use file encoding: Here you need to specify which encoding should be used to read the data from your file.

Different values for different: Choose a desired mode: users, sessions or loop_name iterations.

The list of records is cycled so that if the number of users/sessions/loop iterations is more than the column length, then the 1-st record will be used after the last one.

Number of column in table: Here you should specify the number of column in csv file. WAPT Pro will read the data from that column. The count of columns begins from 0 - it is the number of the first column in the file.

Value delimiter: Here you can specify what delimiter is used to separate different entries in your csv file. However, you can use the selected symbol in the text not as a delimiter, if you place it between symbols selected in the next combo-box (' or ").

String delimiter: If you select ' or " symbol, then all symbols in the table entry located between ' ' (or " ") will be recognized as a text without delimiters. If you select the None option, this feature will be disabled, and selected Value delimiter will be always recognized only as a delimiter.

This function can be used to provide each virtual user with the individual user name and password. If your csv file contains user/password pairs (one column contains usernames and another - passwords), then you need to specify 2 parameters and provide the same csv file for each of them. Only the number of column will be different for these parameters.

Syntax:

$CSV(users,column_number,csv_file_name) for users

$CSV(sessions,column_number,csv_file_name) for sessions

$CSV(Loop_name,column_number,csv_file_name) for loop iterations

If you add this function for requests from embedded loops, use different loop names.

Example:

Suppose, you have a file "C:\Work\Testing\usernames.csv" and its second column is the list of names (name1, name2, name3, etc). You can define a parameter with the values equal to the records of that column. So you specify the following options:

Your function will look as follows:

$CSV(users,1,C:\Work\Testing\usernames.csv)

It results in sending the following HTTP requests:

First virtual user:
POST /login.do
username=name1&...

Second virtual user:
POST /login.do
username=name2&...

Third virtual user:
POST /login.do
username=name3&...

Cookie - $Cookie


This function returns a string containing all currently set cookies which satisfy the search criteria.

The list of cookies is formed during the test run. Each time a new response comes from the server, its header is processed and the list of cookies is updated (new cookies are added, old ones can be modified). The $Cookie function chooses a cookie from this list according to specified parameters (cookie name, domain name and path) for current request.

If you leave the cookie name, domain name and path fields empty, the program will return all cookies set in the server response to current request.
If you specify only cookie name, you will receive all cookies with the specified name.
If the program finds cookies with the specified name, but their domain names or paths do not match the value specified in function properties, then no cookies will be returned (this function will return an empty string).

There is a special option in function properties:

Only Value: If you leave this option unchecked, the function will return a string:

cookie_name=value1; cookie_name=value2; ...
(a set of cookies satisfying the search criteria).

If you check this option, the function will return only value - the value of the first cookie in the returned string of cookies (value1 in this example).

Syntax:

$Cookie(cookie_name,domain_name,path) in case the Only Value option is unchecked, or
$Cookie(cookie_name,domain_name,path,1) in case the Only Value option is checked.

Example:

Suppose you need to retrieve the value of JSESSIONID from the HTTP headers of server responses. For this purpose you define the SessionID parameter which is calculated using $Cookie(JSESSIONID,,/idp) function:



This function will find a cookie with the name JSESSIONID and Path=/idp in the HTTP header of server response and retrieve its value:

HTTP/1.1 200 OK
Date: Fri, 03 Sep 2010 03:32:10 GMT
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Set-Cookie: JSESSIONID=B7490199CC58CBC75889DB9028629F08; Path=/idp; Secure
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 5243
Cache-Control: no-cache
Pragma: no-cache
Cache-Control: no-store
Connection: close

In the current example this function will return
JSESSIONID=B7490199CC58CBC75889DB9028629F08.

If you need to receive only cookie value, you should check the Only Value option in function properties. And the function will return B7490199CC58CBC75889DB9028629F08.

XPath - $XPath


$XPath function supports all features of XML Path Language. In particular, you can use it to select nodes or node-sets in the XML document by specifying some path expression. The node is selected by following the specified path through the document. This function can be used to define the dynamically changing parameter SessionID on XML pages.

Type: Select XPath as function type.

XPath: Here you should enter the sequence of opening tags that stand before a desired node or node-set in the XML document. This sequence can contain variables. Use $Var(var-name) function to insert the necessary variables in the path expression. Enter the $ sign in the XPath field and you will see a prompt with the list of available variables (defined on the previous pages). Select a desired variable in the list to insert it in the path expression.

Only value: Leave this option unchecked if you wish to select the desired node together with the opening and closing tags. If you need to receive only value (without the opening and closing tags), you should check this option.


Syntax:

$XPath({path})
Here path is the sequence of opening tags that stand before the desired node or node-set.
In this case the desired node will be selected together with the opening and closing tags.

$XPath({path},1)
In this case the same node will be selected without the opening and closing tags.

Example 1:

Suppose that the body of server response to some request is the following XML document:



And you define a variable xp equal to

$XPath(/Messages/Message/Value/MessageHeaders/Properties/Property[2]/Value)

to get the content of Value node from this XML document.

In this example, there are 2 properties inside the <properties> node. If you want to select the first property, you should specify Property[1] in path expression. To select the second property, specify Property[2].


As a result, the xp variable will be equal to

<Value type="String" version="3">85F63E4E-131F-0730-446F-44C56419B2C4</Value>

Example 2.

In the previous example you can define $XPath function in the following way:

$XPath(/Messages/Message/Value/MessageHeaders/Properties/Property[2]/Value,1)

In this case the option Only value is turned on in function properties:

As a result, the xp variable will be equal to

85F63E4E-131F-0730-446F-44C56419B2C4


Example 3.

WAPT Pro supports the usage of namespaces in XML documents. Here you can read more about XML namespaces.

If XML document contains namespaces, you should also specify namespaces in the path of $XPath function to find the necessary element. In this example we will show how $XPath function works with namespaces.

Suppose that the body of server response to some request is the following XML document:



Here you can see namespaces bk and isbn. Let's receive the value of number element of isbn namespace. We define $XPath function in the following way:

$XPath(/bk:book/isbn:number)



This function will return the value:

<isbn:number xmlns:isbn="urn:ISBN:0-395-36341-6">1568491379</isbn:number>.

Click the Test button in function properties to see how it works:



You can turn on the option Only value in function properties if you need to receive only value (without the opening and closing tags):



Now the result of this function is equal to 1568491379.



If you need to receive the value of title element of bk namespace, you should define $XPath function in the following way:

$XPath(/bk:book/bk:title)


You can turn on the option Only value in function properties if you need to receive only value (without the opening and closing tags):

Search parameter - $Search


The $Search function is used when dynamic values are surrounded by the certain strings on the left and on the right. This function can search for dynamic values either in the HTML code of the server response to the previous request or in the value of selected variable.

Syntax: VarName=$Search(LeftBoundary,RightBoundary,Index)

Index defines which occurrence of the current parameter to use in case WAPT Pro finds several dynamic values in the HTML code between the specified boundaries. For example, you specified "ItemID=" as the left boundary and "&" as the right boundary and WAPT Pro found the following strings in the HTML code: ItemID=11111111111& and ItemID=222222222&. So 2 dynamic values 11111111111 and 222222222 were found. If the index is equal to 1, the program will use the 1-st occurrence; if the index is equal to 2, then - the 2-nd occurrence and so on. 0 stands for random occurrence.

Example 1:

Suppose the HTML code on some web page contains the following text:

<A HREF="/scdp/page;jsessionid=u8kzzgzsr2">Preparing a test scenario</A>

You can create a variable JSesID which is calculated using the $Search function that searches for dynamic values between the following strings: /scdp/page;jsessionid= (left boundary) and "> (right boundary).

After that you will be able to change the recorded URL path into this one:

/scdp/page;jsessionid=$Search(/scdp/page;jsessionid=,">,0)

and you will obtain the actual URL with a new value of jsessionid.

In this example, the variable JSesID will get the value u8kzzgzsr2. You can set the URL in the subsequent request to use the value of JSesID variable.

Convert special characters ('\r', '\n', '\t', etc.): There are special characters used in C-like programming languages to indicate delimiters in strings:

\n = new line
\r = carriage return
\t = tab etc.

When you use such characters in the strings of left/right boundary of the $Search function, you can convert them to the corresponding delimiters. Check the "Convert special characters" option for this purpose. Otherwise, if you do not check this option, the backslash will not be considered as a special symbol and these characters will not be converted.


Example 2:

This example demonstrates how to organize the search for dynamic values in the value of some variable.

Select the option Variable and type the name of variable. While you are typing, you will see a prompt with the list of existing variables:



You can select the necessary variable here. Or you can click the Select... button and choose a variable in the displayed list. The list includes variables created on one of the previous pages.



This function will search for dynamic values surrounded by the specified strings in the value of selected variable.

Creation of variable initialized by the $Search function


You can select some text in the HTML code of server response (e.g. the value of some variable), right-click on the selection and choose As $Search() command on the displayed menu.



By clicking this command a new variable is created. It is calculated using the $Search function. Symbols surrounding the selected value in server response are used as left and right boundaries for this function.

This variable appears in the list of variables of the current request.

As $Search() command works for the whole server response as well. In this case you get a variable $Search(,,1) with the empty boundaries. You can use this variable to receive the whole server response.

Header - $Header


This function returns the value of a header with the specified name contained in the server response to the latest page request.



Name: Here you should enter the name of the necessary header.

Index: The Index value defines which occurrence of the current parameter to use in case WAPT Pro finds several headers with the specified name. Zero index returns a semicolon-separated concatenation of all values.

Syntax: VarName=$Header(HeaderName,Index)

Example:

Suppose you need to retrieve the value of the first Set-Cookie header contained in the server response to the current page request.



For this purpose you define a parameter calculated using the $Header(Set-Cookie,1) function:



Here the Index value is equal to 1, and WAPT Pro takes the first occurrence of Set-Cookie header.

If you define the Index equal to 0, WAPT Pro will return a semicolon-separated concatenation of all Set-Cookie values:



Session variable is a part of URL path


The functions URL from link and URL from Form cannot be used to define the URL path directly. You should create a variable based on one of these functions and then use that variable in the subsequent request to define the URL.

URL from link - $HRef


This function searches for a link with a specified text in the HTML code of the CURRENT page and returns the URL path from that link. In other words, it searches for a string like
<A HREF=URL path>Text</A> containing the specified Text and returns the URL.

Note: If the link uses a relative path, WAPT Pro automatically transforms it to an absolute path.

Syntax: VarName=$HRef({text},{index},0|1)

Index defines which occurrence of URL to use in case WAPT Pro finds several links with such text. For example, if the index is equal to 1, the program will use the 1-st occurrence; if the index is equal to 2, then - the 2-nd occurrence and so on. 0 stands for random occurrence.

The last parameter indicates whether the following option is checked in function properties or not (1 means "checked", 0 - "not checked").

Decode value: Browsers encode some special symbols, for example, they automatically replace space symbols with "%20" sequence. When you receive a server response with the already encoded symbols, you need to decode them before using in functions. Otherwise you can have double encoding. Check this option to decode all such symbols that start with %.

Example:

Suppose the HTML code of server response contains the following link:

<A HREF="/scdp/page;jsessionid=u8kzzgzsr2">Preparing a test scenario</A>

If you create a variable JSesID equal to $HRef(Preparing a test scenario,1,1), you will obtain the actual URL with a new value of jsessionid.

In this example, the variable JSesID will get the following value:

/scdp/page;jsessionid=u8kzzgzsr2

and you can set the URL in the subsequent request to use the value of JSesID variable.

URL from Form - $Action


Searches the HTML code of the CURRENT page for a form and returns the value of its action attribute.

Note: If the link uses a relative path, WAPT Pro automatically transforms it to an absolute path.

Syntax: VarName=$Action({index},0|1)

Index defines which occurrence of the form to use in case of multiple forms on the page. For example, if the index is equal to 1, the program will use the 1-st occurrence; if the index is equal to 2, then - the 2-nd occurrence and so on. 0 stands for random occurrence.

The last parameter indicates whether the following option is checked in function properties or not (1 means "checked", 0 - "not checked").

Decode value: Browsers encode some special symbols, for example, they automatically replace space symbols with "%20" sequence. When you receive a server response with the already encoded symbols, you need to decode them before using in functions. Otherwise you can have double encoding. Check this option to decode all such symbols that start with %.



Example:

Suppose the HTML code of the current page contains the following form:

<FORM NAME="search" METHOD= "GET" ACTION="/cgi-bin/search.pl;
SessionID=9071C43790244953739594949120B6C8">
<INPUT TYPE="text" NAME="text" VALUE="" MAXLENGTH=80>
<INPUT TYPE="submit" VALUE="Start search">

and this is the first form on the page.

If you create a variable URL_session equal to $Action(1,1), you will obtain the actual URL from that form with an actual value of SessionID. In this example, the URL_session variable will get the following value:

/cgi-bin/search.pl;SessionID=9071C43790244953739594949120B6C8

and you can set the URL path in the subsequent request to use the value of URL_session variable.

Session variable is a request parameter


Functions $UrlParam and $Hidden can be used directly or using variables. Examples below show the direct usage of these functions.

Parameter from URL - $UrlParam


Searches the HTML code of the CURRENT page for a request that contains the specified parameter name and returns parameter value.

Syntax: ParamName=$UrlParam({name},{index},0|1)

Index defines which occurrence of the current parameter to use in case WAPT Pro finds that parameter several times. For example, if the index is equal to 1, the program will use the 1-st occurrence; if the index is equal to 2, then - the 2-nd occurrence and so on. 0 stands for random occurrence.

The last parameter indicates whether the following option is checked in function properties or not (1 means "checked", 0 - "not checked").

Decode value: Browsers encode some special symbols, for example, they automatically replace space symbols with "%20" sequence. When you receive a server response with the already encoded symbols, you need to decode them before using in functions. Otherwise you can have double encoding. Check this option to decode all such symbols that start with %.

Example 1:

Suppose the HTML code of response contains such link:

<A HREF="http://myserver/view?SessionID=FCHHAB02DF&param=test111"></A>

The usage of Myparam=$UrlParam(SessionID,0,1) in the next request will result in the actual value of Myparam=FCHHAB02DF.

This function is very important when you need to use parameter values generated by the server on-the-fly.



Example 2:

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 (a POST request)

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.

You should define the SessionID parameter as $UrlParam(SessionID,0,0) (or $UrlParam(SessionID,0,1)) and thus solve the problems related to SessionID.

Hidden - $Hidden


Searches the HTML code of the CURRENT page for a form containing the specified name of hidden parameter and returns parameter value.

Syntax: ParamName=$Hidden({name},{index})

Index defines which occurrence of the current parameter to use in case WAPT Pro finds that parameter several times (it is the case of multiple forms with the same parameter). For example, if the index is equal to 1, the program will use the 1-st occurrence; if the index is equal to 2, then - the 2-nd occurrence and so on. 0 stands for random occurrence.

This function searches for an element containing <.... name="{name}" value="{value}"> using the specified {name}. The result of the search will be the found {value}. Such syntax is typically used to define input elements in HTML forms. The advantage of this function is that it allows working with hidden form elements and dynamically generated values (for example, session variables).

You can insert variables $Var(var-name) inside a parameter name. Enter the $ sign in the "Name" field and you will see a prompt with the list of available variables (defined on the previous pages). Select a desired variable in the list. After execution of this function, parameter name will contain the calculated values of inserted variables.

Example:

Suppose the HTML code of the current page contains a form with the set of hidden elements:

<form action="/cgi-bin/select.pl" method="get">
<input type="text" name="index" size="25" maxlength="25">
<input type="submit" value="Search">
<input type="hidden" name="UserSession"
value="75893.0884568651DQADHfApHDHfcDtccpfAttcf">
....
....
</form>

To obtain the UserSession value presented as a hidden input, you should define the UserSession variable as $Hidden(UserSession,0).

File - $File


Returns a file with a specified MIME type and name. File content and other request parameters are sent as the POST data of the "multipart/form-data" content type.

This function has a special option Read files directly from load agents. If you check this option, then file content will not be transferred. The function will return only UNC name of the necessary file and its MIME type. Load agents will read the file directly from a specified location. This allows saving the traffic between WAPT Pro Workplace component and load agents, because file content is not sent to agents in this case.

UNC allows specifying network names, e.g.: \\Server\SharedFolder\Folder\File.
You can put the necessary files to some shared folder and all load agents will read them from one place.

The option Read files directly from load agents allows using variables in the names of files. When you check this option, you can use dynamic filenames with the help of $Var(variable-name) function. Enter the $ sign in the Filename field and you will see a prompt with the list of available variables. Select a desired variable in the list to incorporate it into the name of file.

For example, you can use different files for different users (file-0, file-1, file-2 and so on). This can be done with the help of WAPT Pro internal variable User_number. Define a filename as file-$Var(User_number) in the properties of $File function. As a result, the agent will take

file-0 for the first virtual user,
file-1 for the second virtual user,
file-2 for the third virtual user and so on.

Note that if the option Read files directly from load agents is not checked, you cannot use variables in the names of files.

Syntax: ParamName=$File({mimetype},{UNC name of file},0|1)

0|1 - This parameter indicates whether the option Read files directly from load agents is checked in function properties or not (1 means "checked", 0 - "not checked").

Files that you upload can be stored either in a shared network folder, or locally on the computer running load agent or WAPT Pro Workplace component. Note that:

If the option Read files directly from load agents is checked, then local paths are taken from the agent's computer.
If this option is not checked, then local paths are taken from the computer running WAPT Pro Workplace component.

You can use relative folder paths as well.

If you specify a relative path and do not use the option "Read files directly from load agents", then the search will be done from the profile folder. If the file is not found, the search will be continued from the scenario folder.
If you use a relative path and check the option "Read files directly from load agents", then the search will be done on the agent's computer from the directory where the agent's executable file is located.

Example 1:

Suppose you need to upload the JPEG image image001.jpg located in the \\Server\SharedFolder\Folder\ to the tested server. You can define the following function:

$File(application/octet-stream,\\Server\SharedFolder\Folder\image001.jpg,0)

In this example WAPT Pro Workplace component takes the file from a specified location (shared network folder) and sends it to load agents each time this function is called. File content is sent in the body of the corresponding POST request.


Example 2:

This example shows the usage of Read files directly from load agents option. It gives you 2 benefits:

  1. The file is not transferred between WAPT Pro Workplace component and load agents.
  2. You can use variables in the names of files, thus generating dynamic filenames.
Suppose you have a set of files: image0.jpg, image1.jpg, image2.jpg, ... in a network folder. And you wish to perform a test where each virtual user takes the own file from this collection. Let's define the following function:

$File(application/octet-stream,\\Server\SharedFolder\Folder\image$Var(User_number).jpg,1)

As a result, load agents will read different files for different virtual users from a specified location:

image0.jpg for the first virtual user,
image1.jpg for the second virtual user,
image2.jpg for the third virtual user and so on.

Parameter without value


Some web sites require certain request parameters to be passed without a value. To support this situation, WAPT Pro has an option to mark any parameter as having no value.

In request properties click the Add button to add a new parameter.

In the displayed dialog, enter parameter name, select No Value type and click OK. Note that you should not define any function in this case. The new parameter without value will be added to the list of parameters.

Next page