Close

April 22, 2014

LoadRunner Scripting

LoadRunner Scripting

Every performance tester starts performance testing by recording the business process in VuGen. VuGen allows testers to program manually without recording the business actions. You can use Vuser API functions or built-in standard functions. By using those functions, you can measure the server’s response, performance, resource usage etc.

LoadRunner Scripting

You can create scripts in following languages:

  • C
  • Java
  • Visual Basic
  • VBScript
  • JavaScript

Each script in VuGen has following sections: init, action, and end. By default, these sections will be empty. You can manually insert the functions into them.

C Vuser Scripts

Here you can use C syntax that conforms ANSI conventions. You can add comments, conditional flow as similar as writing C program. Following are the limitations of C Vuser script:

  1. stdargs, longjmp, and alloca functions are not supported.
  2. A Vuser script cannot pass the address of one of its functions as a callback to a library function
  3. Do not support structure arguments or return types.
  4. Supports Pointers to structures
  5. String literals are read-only
  6. Do not support any Microsoft extensions to ANSI C
  7. Functions that do not return int must be casted.
  8. Cannot use Microsoft include’s files. You can ask HP customer support for ANSI-compatible

JavaScript Vusers

function Actions()

{

//your code here

      return(lr.PASS);

}

JavaScript Vuser has three sections: Init, Actions, and Terminate respectively. Additionally there is global.js file which creates the objects for API functions and JavaScript.

e.g.

var lr = new ActiveXObject("LoadRunner.LrApi")

VBScript Vusers

You can create a VBScript Vuser script where you can place your VB code.

 

Public Function Actions()

      `your code here

      Actions = lr.PASS

End Function

 

VBScript Vuser has three sections: Init, Actions, and Terminate respectively. Additionally there is global.vbs file which creates the objects for API functions and JavaScript.

Java Vusers

In Java Vusers, you can place any standard java code.

 

import lrapi.lr;

public class Actions

{

    public int init() {

        return 0;

    }

    public int action() {

        return 0;

    }

    public int end() {

        return 0;

    }

}

 

In Java Vuser, you can edit only Actions class. In Action class, we have init, action, and end. Place your initialization code in init, business action in action, and cleanup code in end.

VB Vusers

You can create VB Vusers script to place standard vb code.

Public Function Actions() As Long

      `”your code here

      Actions = lr.PASS

End Function

VuGen creates three sections, vuser_init, action, and vuser_end. Each of these sections contain a VB function – Init, Actions, and Terminate respectively. Additionally, we have a global.vba file, which will have the object and variable global declarations for Vusers and the VB application.

About NaveenKumar Namachivayam

Hi there! is a passionate and experienced Performance Test Analyst based in Chicago, USA with skill sets in Manual Testing, Test Automation, Performance Testing, and Test Estimation. He loves to learn and experiment new trends and models in Software Testing. Please stop by at his personal blogs: Excel Blog, DealsBrook, NaveenKumarN.in, and Affiliate Insights blog and Software Testing Memes.

Leave a Reply

Your email address will not be published. Required fields are marked *