Skip to main content

Layout of a Generated Web Script

General Layout

The general layout of a web virtual user (VU) script generated by Page mode is the same as a script generated by URL mode.

SCRIPT CREATION COMMENTS
// Contains version details of generator and recording generation date
REQUIRED LIBRARIES
// Libraries required for this script to run
WEB VIRTUAL USER SCRIPT CLASS DECLARATION
// All virtual users are object instances
{
WEB VIRTUAL USER SCRIPTCLASS CONSTRUCTOR
{
// Usually empty
}
GLOBAL SCRIPT VARIABLE DECLARATIONS
// Set of variables likely to be required by the script
ACTION 1 METHOD
{
// Navigate to Web page
}
ACTION 2 METHOD
{
// Navigate to Web page
}
.
.
ACTION n METHOD
{
// Navigate to Web page
}
MAIN SCRIPT METHOD
{
// This is the iterated method called at run-time.
// It calls the above methods in the required order
}
}

CREATE WEB SCRIPT MACRO
// This is a macro that hides further script complexity

Action Method

The following example of an Action method is that of a script generated in Page mode.

  int Action1()
{
FcUrl _url; //a URL object for Web navigation

startTransaction("Go To Home");
// ======================================================================================
// Request: 1, GET, http://bosch:8080/, response code=200 OK
// ======================================================================================
// Page Title: Home
// References to the following page resources could not be found within the contents of
// the received web page. This can occur because resources are fetched as a result of
// style sheets or the browser executing script.
_url.addPageResource("http://" + _host1 + ":8080/animal.gif"); // Request: 2
_url.addPageResource("http://" + _host1 + ":8080/banner.gif"); // Request: 3
_url.addPageResource("http://" + _host1 + ":8080/power.gif"); // Request: 4
_url.setHost(_host1);
_url.setPath("/");
_url.setPort(8080);
navigateGet(_url);
verifyPageTitle("Home", ACT_ERROR);

endTransaction("Go To Home");
pause(6516);
return 1;
}

All actions return an integer value. This is set to 1 (true) by default. Each action contains a FcUrl object named _url that is used by the navigation methods.

Properties of the FcUrl are set to the required resource and then navigated to using the appropriate navigate method.

The navigation statements of the action are surrounded by a user transaction entered during recording. All navigations within the startTransaction()/endTransaction() frame are collectively timed to produce a transaction response time.

The pause() statement represents user think-time i.e. the amount of time the user took between one transaction and the next during recording.