LoadRunner Scripting Notes
Customizing the Script Configuraion File
The .usr file is the primary configuration file for the script.
Sample of the internal format is as follows:
[General] Type=QTWeb RecordedProtocol=NoAvailableInfo DefaultCfg=default.cfg AppName= BuildTarget= ParamRightBrace=] ParamLeftBrace=[ NewFunctionHeader=1 LastActiveAction=login CorrInfoReportDir= LastResultDir= DevelopTool=Vugen MajorVersion=8 MinorVersion=1 ParameterFile=Config_DC__01.prm GlobalParameterFile= LastModifyVer=8.1.4.0 [TransactionsOrder] Order="" [Actions] vuser_init=vuser_init.c Recording=Recording.c login=login.c logoff=logoff.c SelectDC=SelectDC.c vuser_end=vuser_end.c [Recorded Actions] vuser_init=0 Recording=1 login=0 logoff=0 SelectDC=0 vuser_end=0 [Replayed Actions] vuser_init=0 Recording=0 login=0 logoff=0 SelectDC=0 vuser_end=0 [Modified Actions] vuser_init=0 Recording=0 login=0 logoff=0 SelectDC=0 vuser_end=0 [RunLogicFiles] Default Profile=default.usp [StateManagement] 1=1 5=0 6=1 7=0 8=0 9=0 10=0 11=0 12=0 13=0 14=0 15=0 CurrentState=6 VuserStateHistory= 0 1048576 LastReplayStatus=0
Customizations
Parameter Delimiters
Some web pages use '{' and '}' in form data - in which case - to avoid errors being generated during script execution replace thse with another character pair such as, '[' and ']'. This can be done either via the GUI (details...) or by modifying the following lines in the .usr file:
ParamRightBrace=] ParamLeftBrace=[
Defining the Parameter Definition File
This is done with the following:
ParameterFile=Config_DC__01.prm
Defining Parameters
Parameters are defined in the .prm (i.e. <SCRIPT>.prm) file. The path to this is defined in 'ParameterFile' in the script configuration file (<SCRIPT>.usr).
Its structure is as follows:
[parameter:Password] Delimiter="," ParamName="Password" TableLocation="Local" ColumnName="Password" Table="Parameters\Users.dat" GenerateNewVal="EachIteration" Type="Table" value_for_each_vuser="" OriginalValue="gerra" auto_allocate_block_size="1" SelectNextRow="Same line as UserId" StartRow="1" OutOfRangePolicy="ContinueWithLast" [parameter:UserId] Delimiter="," ParamName="UserId" TableLocation="Local" ColumnName="UserId" Table="Parameters\Users.dat" GenerateNewVal="Once" Type="Table" value_for_each_vuser="" OriginalValue="pepperm" auto_allocate_block_size="1" SelectNextRow="Unique" StartRow="1" OutOfRangePolicy="ContinueWithLast"
Initially, it makes sense to define parameters via the GUI. However, once you begin to cookie cut scripts it is easier to copy this file into the new script directory. Customize it for the new script (if requried) and add a reference to it into the .usr file as described above.
In some cases, where there are many and complex parameters it might make sense to generate this file automatically using a script (see Generating LoadRunner PRM file).
More on this later...