Subscribe to SoftLogica
Newsletter to get 10% discount on newly
released products!
New Test Scenario Wizard
Parameter Value Dynamic Calculation
Testing of dynamic web sites and applications often requires the usage of dynamic values of request parameters.
If you don't change recorded users' profiles, WAPT simply repeats all requests that
you made during recording, i.e. all virtual users send the same requests to the server. It is suitable to use parameter values generated dynamically at run-time
when you test pages having dynamic content but static URLs. For example, the front page of online store has
static URL and dynamic content. Different users usually select different goods, so they do different
HTTP requests (different parameters or even URI). WAPT can simulate this - different virtual users can do requests
with different parameters. WAPT provides you with various functions for dynamic calculation
of request parameters and URI values at run-time.
All functions in WAPT can be divided into several
groups: random
values (numeric or alphanumeric) values
from list (random or ordered) values
from actual server response (hidden form values and others) others
Results of several functions can also be concatenated to form more complicated
values. WAPT can also upload files to web server
using POST method with multipart content.
There are two methods of functions usage in WAPT:
request
parameter value can be calculated using the combination of functions directly
or you
can define a variable (using functions or other variables) and set request
parameter to use the value
Please note that functions like "Parameter from URL" or "Hidden" which obtain values from actual server response
are calculated using as an input:
HTML code of the PREVIOUS page when function is used for calculation of request PARAMETER value;
HTML code of the CURRENT page when function is used for defining a VARIABLE.
Below is the screenshot of the window where you can define the
formula for calculation of parameter value.
To open this window, select a parameter from the list of parameters:
and click the Edit... button.
Below is the detailed description of all functions.
------------------------------------------------------------------------------------- Variable - $Var
Returns the value of predefined variable. Variables help to handle different
user-dependent parameters like session IDs or viewstates.
Variable can be defined by any function and redefined later if necessary.
Please note that functions which obtain values from actual server response (hidden form values and others) use HTML code of the CURRENT
page as an input when they are used for defining a variable.
Syntax: $Var({name})
------------------------------------------------------------------------------------------------
Ordered list - $List
Returns the 1-st string from specified list for the 1-st user/iteration,
the 2-nd string for the 2-nd user/iteration and so on. To specify the
list, type one string per line or specify the name of file containing
the list. The list is cycled so that if the number of users/iterations
is greater than the list length, then the 1-st string will be used after
the last one.
For example, this function can be used to provide each virtual user with individual user name and password.
Syntax:
$List(0|1,{file_name}|value1[,{value2},…])
0 stands for iterations, 1 stands for users. Example: $List(1,John,Mike,Bob)
Results in sending 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&... ------------------------------------------------------------------------------------------------
Random from list - $LRand
Returns the random string from specified list. To specify the list, type
one string per line or specify the name of file containing the list.
Syntax:
$LRand({file_name}|value1[,{value2},…])
Example: $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
------------------------------------------------------------------------------------------------
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 from the [from,to] range
preceded by a {prefix}
(if one specified). Example:$NRand(1,20,ID) 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 in specified
range. Syntax: $ARand({from},{to}) Example: $ARand(1,20)
It results in sending HTTP requests like: http://myserver/view?param=g
http://myserver/view?param=fndy5lgs5pck
http://myserver/view?param=xfglfgjl4asd098ljk6c
---------------------------------------------------------------------------------------------- User number - $UserID Returns the concatenation of prefix string, the number of current virtual user (starts from 0) and the 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 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 prefix string and an integer number with some leading zeros (if the length
of integer is less than the value specified in Width field). Syntax: $Seq({prefix},{startvalue},{virtualusershift},{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
---------------------------------------------------------------------------------------------- Hidden - $Hidden
Returns the value of hidden parameter from HTML code of response to the
PREVIOUS request. Syntax: ParamName=$Hidden({name},{index})
Index defines which occurrence of specified parameter should be used (multiple forms with the same parameter).
0 stands for random occurrence.
This function searches for an element containing <....
name="{name}" value="{value}"> using the specified {name}.
The found {value} will be used. Such syntax is typically
used to define input elements in HTML forms. The advantage of this function
is that it allows to work with hidden form elements and dynamically generated
values (for example, Session
variables).
Example:
Response to the previous HTTP request 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="restrict1" value="yes"> <input type="hidden" name="restrict3" value="no"> ....
....
</form> To use values of hidden input in the next request, you should define $Hidden function for restrict1 and restrict3 parameters.
------------------------------------------------------------------------------------------------ Parameter from URL -
$UrlParam
Searches HTML code of the PREVIOUS page for GET or POST request that contains
the specified parameter and returns its value. Syntax: ParamName=$UrlParam({name},{index})
Index defines which occurrence of specified parameter should be used (multiple forms with the same parameter).
0 stands for random occurrence. Example 1:
HTML code of response contains: <A HREF="http://myserver/view?SessionID=FCHHAB02DF¶m=test111"></a> The use of Myparam=$UrlParam(SessionID) in the next request
will result in the actual value of Myparam=FCHHAB02DF.
This function is very useful when you need to use parameter values generated
by the server on-the-fly. This relates, e.g., to various session
variables. Example 2:
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 particular resource: http://myserver/view?SessionID=FCHHAB02DF&Category=main&Item=67
During recording, WAPT records this sequence of HTTP requests, but the
static value of SessionID would not be used to playback this sequence
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 set $UrlParam(SessionID) for SessionID parameter and thus solve the problems related to
SessionID.
------------------------------------------------------------------------------------------------
File - $File Returns the file with specified name and mime type. File content and other request parameters will be sent as
POST data with "multipart/form-data" content type.
Syntax: ParamName=$File({name},{mimetype})
If you need to upload the JPEG image image.jpg located
in the C:\Graphics\Jpg\ folder, you
should use the following function: $File(C:\Graphics\Jpg\image.jpg,image/pjpeg)