Skip to main content

Auto Parameterization

URLs

Host

The host names of all URLs within a generated Web script are auto parameterized through use of the generated variable _hostn, where n is an instance of a host. Many hosts can be navigated within a single script. Parameterization is achieved via getString() with the default argument set to the host value encountered at the time of recording.

In the following example the script was recorded against the host bosch and will replay against this host unless a data source is set up containing a value for _host1.

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;
}

public: void script()
{
_host1 = getString("_host1", "bosch");

Action1();
Action2();
Action3();
Action4();
Action5();
Action6();
Action7();
}

User Agent Header

The user agent string is a header name/value pair sent by the client in order to tell the server what type of agent is making the request. User agents are typically browser types. Parameterization is achieved via getString() with the default argument set to the browser used for recording.

In the following example the user agent string is set to Internet Explorer 7 and will replay as such unless a data source is set up containing the value for "User-Agent".

void setOptions()
{
setUserAgent(getString("User-Agent","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)"));
}