Saturday 27 April 2013

LoadRunner Tutorial



3
Building Scripts
To create load, you first build automated scripts that emulate real user
behavior.
In this lesson you will cover the following topics:
Introducing the Virtual User Generator (VuGen)
How do I start recording user activities?
Using VuGen Wizard Mode
How do I record a business process to create a script?
How do I view the script?
Introducing the Virtual User Generator (VuGen)
In a testing environment, LoadRunner replaces human users at physical
machines, with virtual users, or a Vusers. Vusers create load on a system by
emulating actions of typical users in a repeatable and predictable manner.
The LoadRunner Virtual User Generator (VuGen) works on a record-andplayback
principle. As you walk through a business process on your
application, VuGen records your actions into automated scripts which will
form the foundation of your load tests.
Note: If you have completed the HP LoadRunner Quick Start, you will
notice that the script steps that you recorded there are identical to those
that you will record in the following section. However, the overall recording
process is explained here in greater detail.

How do I start recording user activities?
To begin recording user actions, you open VuGen and create a blank script.
You fill the blank script by recording events and adding manual
enhancements.
In this section, you will open VuGen and create a blank Web script.
1 Start LoadRunner.
Choose Start > Programs >LoadRunner>LoadRunner. The HP LoadRunner
Launcher window opens.
 

2 Open VuGen.
In the Launcher window, click the Load Testing tab.
Click Create/Edit Scripts. VuGen’s Start Page opens.

Using VuGen Wizard Mode
The empty script opens in VuGen’swizard mode with the Task pane
displayed on the left. (If the task pane is not displayed click the Tasks button
on the toolbar. If the Start Recording dialog box opens automatically, click
Cancel).
VuGen’s wizard takes you through a step by step process of creating a script
and then adapting it for your test environment.
The Task pane lists each step or task in the script creation process. As you
proceed through each step, VuGen displays detailed instructions and
guidelines in the main area of the window.
 
You can customize your VuGen window to show or hide the various
toolbars. To show or hide a toolbar, choose View > Toolbars and toggle the
check mark adjacent to the desired toolbar.
You return to the VuGen wizard at aany stage by opening the task pane and
clicking on one of the task steps.

How do I record a business process to create a script?
The next step in creating user emulation, is recording the events performed
by a real user. In the previous section, you created an empty Web script.
Now you can begin to record events directly into the script. In this section,
you will track the events of one passenger reserving a flight from Denver to
Los Angeles and then checking the flight itinerary.
To record the script:
1 Start recording on the HP Tours Web site.
Click Record Application in step 1 in the Task pane.
Click Start Recording at the bottom of the instruction pane.

Alternatively you can choose Vuser>Start Record or click the Start Record
button in the Toolbar at the top of the page.
9 Choose File > Save or click the Save button. Type basic_tutorialin the File
name box and click Save. VuGen saves the file in the LoadRunner script
folder and displays the test name in the title bar.
How do I view the script?
You have now recorded a travel agent logging in, booking a flight, and
logging off. VuGen recorded your steps from the moment you clicked the
Start Record button to the moment you clicked the Stop button.
You can now view the script inside VuGen. You can view the script in Tree
viewor Script view. Tree view is an icon-based view that lists the actions of
theVuser as steps, while Script view is a text-based view that lists the actions
of the Vuser as functions.



Tree View
To view the script in Tree view choose View > Tree View or click the Tree
view button. To view the Tree View across the whole window, remove the
Task pane by clicking the Task button.
 
For each step you performed during recording, VuGen generated an icon
and a title in the test tree. In Tree view, you see the actions of the user as
script steps. Most steps are accompanied by a corresponding snapshot of the
recording.
The snapshots make the scripts easier to understand, and easier to share
between engineers because you can see exactly which screen was recorded
during the recording process. You can compare the snapshots afterwards to
verify your script’s accuracy. VuGen also creates snapshots of each step
during replay.
Click the plus (+) sign adjacent to any of the steps in the test tree. You now
see the Think Time that was recorded while you were booking a flight. Think
Time represents the actual time you waited between steps, and can be used
to emulate fast and slow user behavior under load. Think time is a
mechanism whereby you can make your load test more accurately reflect a
real user’s behavior.

Script View
Script view is a text-based view that lists the actions of the Vuser as API
functions. To view the script in Script view choose View > Script View or
click the Script View button.

In Script view, VuGen shows the script in an editor with color coded
functions and their argument values. You can type C or LoadRunner API
functions, as well as control flow statements, directly into this window

No comments:

Post a Comment