In last few articles, you have learnt about basics about LoadRunner/VuGen. In this article, you are going to learn about LoadRunner Script Structure by creating a web based protocol. It is always best to learn how the script is structured and framed in LoadRunner. It will help you in analysis, if you face any problems. Read on further to know more about LoadRunner Script Structure. I am assuming that you are learning Web HTTP/HTML protocol, so the example mentioned below is only for Web HTTP/HTML protocol.
Table of Contents
LoadRunner Script Structure
Whenever you create a new Web HTTP/HTML script (single protocol), in Solution Explorer, you can see below items. By default, LoadRunner creates three Actions: vuser_init, Action, and vuer_end. In Extra Files, it will generate default globals.h.
In my project, I record Login business transaction under vuser_init; subsequent business actions under Action or multiple Actions, and logoff under vuser_end action. It will be convenient to define the loop in Runtime settings.
Once you save your script locally, and navigate to the saved path, you can see there will lot of files generated as shown below.
By default, scripts will be saved under C:\Users\<User Name>\Documents\VuGen\Scripts [Windows 7]. Below is the sample folder structure for Web HTTP/HTML script.
*.c files
Vuser_init.c, Action.c, and vuser_end.c contains the actual code which was generated by LoadRunner or scripted by tester. This contains actual business process or recorded steps or scripted logics.
Bookmarks.xml
This xml file contains the bookmark information which you had created in VuGen. Below is the sample xml file.
<?xml version=”1.0″ encoding=”utf-8″?><Bookmarks><Bookmark filename=”Action.c” linenumber=”3″ /></Bookmarks>
Bookmarks can be created, toggled, deleted in Bookmark pane. You can launch Bookmark pane by pressing Ctrl + Alt + K shortcut.
Breakpoints.xml
This xml file contains all the breakpoints which was created by the user during debugging. Below is the sample xml file. Breakpoints can be created and toggled by pressing F9 key.
<BreakpointsRoot Version=”1″>
 <Breakpoint Line=”3″ Enabled=”True” FilePath=”Action.c” />
</BreakpointsRoot>
Default.usp
This usp file contains the script’s run logic. Below is the sample contents. Each section defines how the action should run. It is ideal not to edit this file.
[RunLogicEndRoot:vuser_end]
MercIniTreeSectionName=”vuser_end”
RunLogicObjectKind=”Action”
Name=”vuser_end”
MercIniTreeFather=”RunLogicEndRoot”
RunLogicActionType=”VuserEnd”
[RunLogicInitRoot:vuser_init]
MercIniTreeSectionName=”vuser_init”
RunLogicObjectKind=”Action”
Name=”vuser_init”
MercIniTreeFather=”RunLogicInitRoot”
RunLogicActionType=”VuserInit”
[RunLogicRunRoot:Action]
MercIniTreeSectionName=”Action”
RunLogicObjectKind=”Action”
Name=”Action”
MercIniTreeFather=”RunLogicRunRoot”
RunLogicActionType=”VuserRun”
[RunLogicErrorHandlerRoot:vuser_errorhandler]
MercIniTreeSectionName=”vuser_errorhandler”
RunLogicObjectKind=”Action”
Name=”vuser_errorhandler”
MercIniTreeFather=”RunLogicErrorHandlerRoot”
RunLogicActionType=”VuserErrorHandler”
[Profile Actions]
MercIniTreeSectionName=”Profile Actions”
Profile Actions name=vuser_init,Action,vuser_end
MercIniTreeFather=””
[RunLogicRunRoot]
RunLogicActionOrder=”Action”
MercIniTreeFather=””
MercIniTreeSons=”Action”
RunLogicNumOfIterations=”1″
Name=”Run”
RunLogicRunMode=”Sequential”
RunLogicObjectKind=”Group”
RunLogicActionType=”VuserRun”
MercIniTreeSectionName=”RunLogicRunRoot”
[RunLogicErrorHandlerRoot]
RunLogicActionOrder=”vuser_errorhandler”
MercIniTreeFather=””
MercIniTreeSons=”vuser_errorhandler”
RunLogicNumOfIterations=”1″
Name=”ErrorHandler”
RunLogicRunMode=”Sequential”
RunLogicObjectKind=”Group”
RunLogicActionType=”VuserErrorHandler”
MercIniTreeSectionName=”RunLogicErrorHandlerRoot”
[RunLogicEndRoot]
RunLogicActionOrder=”vuser_end”
MercIniTreeFather=””
MercIniTreeSons=”vuser_end”
RunLogicNumOfIterations=”1″
Name=”End”
RunLogicRunMode=”Sequential”
RunLogicObjectKind=”Group”
RunLogicActionType=”VuserEnd”
MercIniTreeSectionName=”RunLogicEndRoot”
[RunLogicInitRoot]
RunLogicActionOrder=”vuser_init”
MercIniTreeFather=””
MercIniTreeSons=”vuser_init”
RunLogicNumOfIterations=”1″
Name=”Init”
RunLogicRunMode=”Sequential”
RunLogicObjectKind=”Group”
RunLogicActionType=”VuserInit”
MercIniTreeSectionName=”RunLogicInitRoot”
ScriptUploadMetadata.xml
This xml file contains the details about the script such as script name, protocol type, action files etc. Below is the sample content.
<?xml version=”1.0″ encoding=”utf-8″?>
<VugenScriptMetadata>
 <ScriptName>WebHttpHtml40</ScriptName>
 <Protocol>Web – HTTP/HTML</Protocol>
 <ActionFiles>
   <FileEntry Name=”vuser_init.c” Filter=”2″ />
   <FileEntry Name=”Action.c” Filter=”2″ />
   <FileEntry Name=”vuser_end.c” Filter=”2″ />
 </ActionFiles>
 <GeneralFiles>
   <FileEntry Name=”WebHttpHtml40.usr” Filter=”4″ />
   <FileEntry Name=”default.cfg” Filter=”4″ />
   <FileEntry Name=”default.usp” Filter=”4″ />
   <FileEntry Name=”globals.h” Filter=”2″ />
   <FileEntry Name=”ScriptUploadMetadata.xml” Filter=”2″ />
   <FileEntry Name=”Bookmarks.xml” Filter=”2″ />
   <FileEntry Name=”Breakpoints.xml” Filter=”2″ />
   <FileEntry Name=”UserTasks.xml” Filter=”2″ />
   <FileEntry Name=”custom_body_variables.txt” Filter=”1″ />
   <FileEntry Name=”lrw_custom_body.h” Filter=”1″ />
   <FileEntry Name=”ThumbnailsCache.tmp” Filter=”1″ />
 </GeneralFiles>
</VugenScriptMetadata>
UserTasks.xml
This xml contains information about the tasks added to the script. Below is the sample task details. Tasks can be added, deleted, and tracked in Tasks pane.
<?xml version=”1.0″ encoding=”utf-8″?>
<App Name=”HP Virtual User Generator”>
 <Tasks>
   <Task>
     <type>UserTask</type>
     <category>Default</category>
     <description>Fix the login action</description>
     <completed>false</completed>
     <project>WebHttpHtml40</project>
     <properties>
       <CreationTime>01/06/2016 15:49:38</CreationTime>
       <Priority>High</Priority>
       <Author>nnama</Author>
     </properties>
   </Task>
 </Tasks>
</App>
<ScriptName>.usr
USR file contains information about Vuser type, Actions, versions, profile etc. Below is the sample content of usr file.
[General]
Type=Multi
DefaultCfg=default.cfg
ParameterFile=
GlobalParameterFile=
NewFunctionHeader=1
RunType=cci
ActionLogicExt=action_logic
MajorVersion=12
MinorVersion=2
LastActiveAction=Action
ActiveTypes=QTWeb
GenerateTypes=QTWeb
AdditionalTypes=QTWeb
DevelopTool=Vugen
LastModifyVer=12.2.0.0
ParamLeftBrace={
ParamRightBrace=}
ScriptLanguage=C
DisableRegenerate=0
Description=
[Actions]
vuser_init=vuser_init.c
Action=Action.c
vuser_end=vuser_end.c
[RunLogicFiles]
Default Profile=default.usp
[VuserProfiles]
Profiles=Default Profile
[CfgFiles]
Default Profile=default.cfg
[ExtraFiles]
globals.h=
[Modified Actions]
vuser_init=0
Action=0
vuser_end=0
[Recorded Actions]
vuser_init=0
Action=0
vuser_end=0
[Replayed Actions]
vuser_init=0
Action=0
vuser_end=0
[Interpreters]
vuser_init=cci
Action=cci
vuser_end=cci
[TransactionsOrder]
Order=
[StateManagement]
LastReplayStatus=0
[ActiveReplay]
LastReplayedRunName=
ActiveRunName=
ThumbnailsCache.tmp
ThumbnailsCache.tmp is a temporary file which will get created while creating a new file.
default.cfg
default.cfg contains information about think time, iterations, log, web etc. Below is the sample content of default.cfg.
[General]
XlBridgeTimeout=120
DefaultRunLogic=default.usp
automatic_nested_transactions=1
AutomaticTransactions=1
[ThinkTime]
Options=NOTHINK
Factor=1
LimitFlag=0
Limit=1
[Iterations]
NumOfIterations=1
IterationPace=IterationASAP
StartEvery=60
RandomMin=60
RandomMax=90
[Log]
LogOptions=LogBrief
MsgClassData=0
MsgClassParameters=0
MsgClassFull=0
[WEB]
SearchForImages=1
WebRecorderVersion=8
MaxConnections=0
LogFileWriteTraceToFile=0
LogFileWrite=0
*.h files
Header files contains all the header definitions which will be used by *.c files.
custom_body_variables.txt
This file contains the variable name assigned to the body sections recorded for web_custom_request function.
lrw_custom_body.h file
This file contains the body sections recorded for web_custom_request function.
Above are the types of files which will be generated when you create a new Web – HTTP/HTML protocol in VuGen. In next article, we will see about the files which will be created during recording.