Basics of LoadRunner Scripting

The simplicity, convenience of scripting, execution, and result analysis of LoadRunner are well known. You were given a high-level overview of all the fundamental procedures we take when performing performance testing with LoadRunner in the post titled “LoadRunner Basic Steps.” You must go through all of the subjects in the LoadRunner Tutorial to gain more information on each step. In this post, you will discover the crucial elements for producing a flawless LoadRunner script, starting with the fundamentals of LoadRunner scripting.

      Except for particular protocols, LoadRunner (VuGen) operates on the ‘Record and Replay’ principle.

If you’re just starting off, you should be familiar with the “Record and Replay” concept. ‘Record and Replay’ in this context only refers to scripting. The business flow (or user activities) can be recorded by merely browsing the web pages in the browser, and VuGen (the LoadRunner’s scripting component) records the communication between the browser and the server.

VuGen turns the recorded flow into a program named “Script” after recording. All of the user activities you took, while the recording was being made, are included in the recorded script. To confirm that the flow and business process is right, you can replay the script.

It is quite uncommon to succeed on the first try. This is due to the fact that certain websites contain security checks that can be handled with little extra coding. As a result, the recorded script needs to be modified, a process known as “script debugging.”

Let’s now get deeper into the specifics of scripting steps:

Basic LoadRunner Scripting Steps:

See the flowchart below (Figure 01). The LoadRunner scripting process consists of 5 basic steps:

  • Upload
  • Protocol
  • Identification
  • Recording
  • Debugging
  1. Protocol Identification:
      The first stage in script recording is protocol identification. You must be familiar with the technology and platform of the application on which the script will be written. Ask the application architect or developer for these details if you are unsure. Prior to Micro Focus’ discontinuation, VuGen included a tool named “Protocol Advisor” to help identify the supportive protocol. As a result, you must independently gather knowledge on protocols and select the appropriate one.
  2. Script Recording:
      As was already noted, the main benefit of LoadRunner is its recording feature, which saves performance testers time and effort by automating the writing of manual code for 80%–90% of protocols. In some circumstances, custom code must be written, although those instances require only basic logic.

    You can start script recording by simply surfing the websites in accordance with the business flow after choosing the appropriate protocol. Once the flow is over, the recording can be stopped. To scan the recording logs and produce the script, VuGen needs some time.

    Keep in mind that the online service (protocol) does not adhere to the recording practice, thus its script production procedures diverge.
  3. Script Debugging:
    Correlation: Although it includes an autocorrelation capability, LoadRunner generates a very basic script that cannot handle dynamic values arriving from the server. Undoubtedly, the question “What is the dynamic value?” pops into your head. For security reasons, the server generates various distinctive values, such as sessionIDs and permission tokens, which the script must manage. ‘Correlation’ is the LoadRunner term for the handling of dynamic values.

    If you play back a freshly recorded script without making any changes, the script might not work because of a correlation problem. because the server will reject it because it passes an outdated (recorded) dynamic value. As a result, you must locate the dynamic values in the script and use correlation when necessary. As was already noted, LoadRunner features an auto-correlation capability that can recognize dynamic values automatically, however, it is not always effective. The issue of correlation will be covered in more detail later.

    Flow logic: On occasion, you must create original code to manage user activities. A hotel booking website might include all the hotels and indicate whether they are booked or available. According to the business case, a user must only select hotels with an “Available” occupancy status. If you were to replay the script with the recorded hotel that had been reserved while recording, the script would attempt to do the same while the server would reject it and throw an error. Finally, a script failure notice will appear. You now need to create a custom logic that only books available hotels after first checking the hotel’s occupancy status.

    Content check: Examining the text or image that is displayed on a webpage aids in validating the response. This is a crucial check to see whether the target page has loaded or not. There are two types:
    • Text check: To validate the text in the response.
    • Image check: To verify the availability of the image in the response.
  4. Script improvement:
    This stage, which comes after recording and debugging, gives the script some aesthetic appeal. Some crucial phases in script improvement are script factorization and parameterization. You can skip some of the stages because they are optional.
    • Parameterization: Using parameters allows you to use the test data instead of the script’s hardcoded values. To replace a value with a parameter in VuGen, simply select the value, right-click on it, and choose “Replace with parameter” or “Use existing parameter”.
    • Add/Edit Transactions If not specified at the time of recording, you can add or edit transactions. Transactions represent user actions. Help track the delay and failure of a specific request or user action. The transaction name can be provided both during registration and after registration. In addition, you can quickly modify a transaction name if you don’t follow the business process or if you choose to change it.
    • Meeting Points: At any point in the script, meeting points help to achieve user concurrency. A touchpoint significantly increases the user load on the server and allows LoadRunner to assess the capacity of the server for that specific operation. For more information about the meeting point and the policy, click on the link.
    • Add/Edit Think Time: A real user stopping while reading the content of a page is known as “think time”. Increases the realism of a scenario. Inserting the think time (lr_think_time(n), where n is a delay in seconds) between two transactions is a good idea. In the script, there is a function for the registered think time whose value can be changed.
    • Update runtime configuration – The runtime configuration gives the Vuser script general control. You can make any necessary updates. Typically, execution logic, think time, pacing, enable/disable logging, and other topics are covered.

      VuGen runtime configuration can be overridden by Performance Center/Controller.

  5. Upload the script to Controller or Performance Center:
    The finished script must be uploaded to Performance Center or Controller for execution. You must ensure the following before submitting the script:
    • The script should run for multiple users as well as multiple iterations without any failure.
    • The script should follow the correct business flow and give the expected output.
    • Disable/Enable (minimum level) log as per requirement.
    • The script should have an appropriate runtime setting.
    • The custom logic should be outside the business transaction.
    • The script should have calculative thinking time and pacing. 

These LoadRunner programming fundamentals will enable you to write flawless, fully automated scripts. To learn more about a certain topic that was difficult to cover in the basics, click on the links provided.

Scroll to Top