Due to the way scripts are captured in AgileLoad (at the HTTP level), the script must be able to handle session parameters and similar variables in the same way that the browser that it is emulating would.
To that end the script must be parameterised. This parameterisation process can be automated by teaching AgileLoad how to do this in its models. However before doing this you will need to understand the parameterisation process which is explained here.
What follows are before and after screenshots of a snippet of script before the model has been executed and after, 1st is before, notice the parameters starting with __, these are standard Microsoft .Net parameters, the strings are hard coded at the moment:
After the model has executed the script looks like this (below), notice that the hardcoded values are now replaced with script variables:
In this situation a script has been recorded against a SharePoint application. After the recording process has completed the ‘Session identifiers assistant’ pops up, it will attempt to choose the correct model to deal with the script. In the case of SharePoint it will choose the .Net & SharePoint model. This is an automatic model in play; however what we see is that while the standard .Net and SharePoint parameters such as __VIEWSTATE, __EVENTVALIDATION, __EVENTTARGET etc. have been dealt with the additional parameters that are not standard with .Net and SharePoint are not dealt with – see the sessionUID below:
This is because that model knows nothing about these other parameters and does not know how to parameterise them. Eventually you will want to create a model to do that but for the moment we’ll go through the process of doing this manually.
In the example below we can see that the sessionUID has not been parameterised in this case we do want to make it a dynamic value as this value will change for each user and possible each transaction that we have with the server. We need to have AgileLoad extract the value form the correct response and use it in the relevant ensuing requests. (Tip: use CTRL-F2 to place a bookmark in the script to make it easy to find your way back.) To start we highlight the parameter, right click and choose Find & Replace then Find in HTTP Responses (see below):
This brings up a list of every response that has that string inside it in the ‘Find In HTTP’ tab in the lower window. As the string originates from the server we must choose the first response where we see the AgileLoad has seen the string. In this case there are multiple instances of that string in response 89 (see Id column).
Note that the response to extract the string from must occur before the point at which we need to use the string in a subsequent request. The script can’t of course use a string that does not exist yet! The order of extraction and use is very important for parameters like these. Double clicking on that response will open it up in the right hand ‘HTTP Details’ window with the string highlighted (see below):
Notice also the yellow arrow in the left hand margin of the script; this denotes the line (request) in the script that the window on the right relates to. Also notice that the IDENTIFIER is 88, one number lower than the ID of the response. This will always be the case as the request happens immediately before the response.
The way that AgileLoad will extract the string is by identifying the text immediately to the left and immediately to the right it; obviously these values must be unique. In this case it looks like the values might not be unique as they are fairly standard HTML tags. So we either would need to extend the left and right strings out until they are unique, specify an instance (i.e. 1st, 2nd 3rd instance of this string etc.) or try to pull the string from a different location. Here we are fortunate in that the target string appears in 4 places in the response (there are four instances of ID 89 in the Find in HTTP window). Investigating each of these will prove worthwhile and may reveal an easier way to extract he string that we need.
Here we can see that the 3rd line refers to an instant with what appear to be unique left and right strings:
Right clicking the string and choosing ‘Extract value…’ pops out the Parse interface, it is pre-populated with the left and right search strings (although they are a little truncated – you can extend these if you prefer), we have a magnifying glass button – this is important as it lets us test the extract conditions. Clicking on it open the ‘Value’ window which shows what will be extracted:
This value is not identical to the value that we want as it is surrounded by curly brackets. Rather than extract it that way and perform some string action in the script there may be a better way to extract the string, testing the extract conditions and altering the occurrence is successful! We see that below the value we really need to extract is between the 3rd occurrence of those left and right strings:
Now we are happy with the string that will be extracted we can use it. We need to specify a name for the script variable (you can use anything so long as it is not an AgileLoad reserved word) and then we need to click Apply. This will enter the code into the script to make the extract of the value from the server response:
Now all we need to do is replace the hard coded value in the script. Navigate back to where we saw the hard coded value originally and replace it, you can do this by using the F2 key if you created a bookmark before moving away from it, alternatively just go to the top of the script and search for the target parameter name – note that there may be multiple instances of this name.
Once you’ve found it replace the hard coded literal value like below:
With the variable you created like below:
And that parameter is dealt with. However that was quite a lot of work just to deal with one parameter and while AgileLoad makes it relatively easy when compared to other tools it’s still not really satisfactory to have to do that each time you record a new script. What we really need to do is to teach AgileLoad how to deal with those parameters. That is covered in the Automatic Parameterisation section.
Next Manual script parametrisation video