Lesson 1: Building a Vuser Script

To generate a load on your system, you first build a Vuser script that you can run to emulate real user behavior. You use VuGen to create and build Vuser scripts.

In this lesson you will cover the following topics:

Introducing VuGen - the Virtual User Generator

In a performance testing environment, LoadRunner replaces human users with virtual users, also known as Vusers. Vusers generate a load on a system by emulating actions of typical users - in a repeatable and predictable manner.

You use VuGen (LoadRunner's Virtual User Generator) to create Vuser scripts. VuGen works on a record-and-playback principle. As you walk through a business process on your application, VuGen records your actions and transforms these actions into steps in a Vuser script. These Vuser scripts form the foundation of your load tests.

Back to top

Creating a Blank Vuser Script

To develop a Vuser script, you first open VuGen and create a blank script. Thereafter, you can enhance the blank script by recording events and adding manual enhancements to the script.

In this section, you will open VuGen and create a blank Vuser script that is based on the Web - HTTP/HTML protocol.

To create a blank Vuser script:
  1. On the LoadRunner machine, double-click the Virtual User Generator shortcut icon on the desktop to open VuGen.

  2. Click the Add New Script button on the VuGen toolbar, or select File > New Script and Solution. The Create a New Script dialog box opens.

  3. Under Category, select Single Protocol. VuGen displays (in alphabetical order) the available protocols for a single-protocol script.
  4. Select Web - HTTP/HTML and click Create.

    VuGen creates a blank Vuser script and displays the script in the VuGen Editor.

Back to top

Recording a Vuser script

The next step in developing the Vuser script is to record the actions performed by a real user. In the previous section, you created an empty Web - HTTP/HTML Vuser script.

Now you can begin to record actions directly into the script. You will track the actions that a travel agent performs to reserve a flight from Denver to Los Angeles, and check the flight itinerary.

Note: To enable VuGen to record the actions that you perform in the Web Tours application, click Record > Recording Options. In the Recording Options dialog box, select General > Script, and then under Scripting Options, make sure that the Track processes created as COM local servers check box is cleared.

To record the Vuser script:

  1. Start recording on the Web Tours web site.

    1. Click Record > Record or click the Record button on the VuGen toolbar. The Start Recording dialog box opens.

    2. In the Record into action box, select Action.
    3. From the Record list, select Web Browser.
    4. In the Application box, make sure that Microsoft Internet Explorer appears.
    5. In the URL address box, type the URL address:

    6. Click Start Recording. A new web browser opens and displays the Web Tours home page.

      Note: If there is an error opening Web Tours, make sure that the Web Tours Server is running. For details, see Web Tours Sample Application.

      VuGen's floating Recording toolbar opens.

  2. Log on to Web Tours.

    1. Type in the following information:

      - User name: jojo

      - Password: bean

    1. On the left pane, click Login. Web Tours welcomes you to the application.
  3. Enter the flight details.

    1. Click Flights. The Find Flight page opens.

    2. From Departure City, select Denver (default).

    3. Departure Date: Keep the default date.

    4. From Arrival City, select Los Angeles.

    5. Return Date: Keep the default date.

    6. From Seating Preference, select Aisle.

    7. Keep the rest of the default settings and click Continue. The Find Flight page opens.
  4. Select a flight.

    Click Continue to accept the default flight selections. The Payment Details page opens.

  5. Enter payment information and book the flight.

    1. In the Credit Card box, enter 12345678.

    2. In the Exp Date box, enter 06/19.
    3. Click Continue. The Invoice page opens, displaying your invoice.
  6. In the left pane, click Itinerary. The Itinerary page opens.

  7. In the left pane, click Sign Off.

  8. Close the browser, and then click the Stop Recording button on the VuGen floating toolbar to stop the recording process.

    VuGen generates the required code and inserts the code into the Vuser script.

    If the Design Studio opens, click Close to close the Design Studio.

  9. Save the Vuser script.
    1. Select File > Save Script As.
    2. Navigate to <LoadRunner root>\tutorial, create a new folder named Scripts, and then navigate to the new Scripts folder.
    3. In the File name box, type basic_tutorial.
    4. Click Save. VuGen saves the script and displays the script name in the VuGen title bar.

Back to top

Viewing the Vuser script

You have now recorded the actions of a travel agent logging in, booking a flight, checking the itinerary, and logging off. VuGen recorded your steps from the moment you clicked the Start Recording button to the moment you clicked the Stop Recording button.

You can now use VuGen to view the script. VuGen lets you see the Vuser script in a number of formats:

  • The Solution Explorer gives you structured access to the various parts of a Vuser script, as well as to a number of files that are associated with the Vuser script.

  • The Step Navigator displays an icon-based view of the script that lists the actions of the Vuser as steps. For each action you performed during recording, VuGen generated a corresponding step in the Step Navigator.

    The Step Navigator displays a snapshot icon to indicate that a specific step contains a snapshot.

    To view the script in the Step Navigator, select View > Step Navigator, or click the Step Navigator button on the VuGen toolbar. Double-click any step in the Step Navigator to display the corresponding function in the Editor.

  • The VuGen Editor displays a text-based view of the script. In the Editor, the actions of the Vuser are listed as API functions. In the Editor, VuGen uses color-coding to show the functions and their argument values in the script. You can type C or LoadRunner API functions, as well as control flow statements, directly into the script.

Back to top

Next steps: