Open topic with navigation
Functions and constants that use the C language syntax have prefixes that indicate the type of functionality. For example, general utility functions have an "lr" prefix, constants have an "LR" prefix, web functions have a "web" prefix, FTP functions have an "ftp" prefix, and so on.
With object oriented languages, functions and constants require the object reference. When working with VuGen, the objects are sometimes created for you, and the object identifiers are hard coded. Common object references are "lr", "lrapi", and protocol specific objects like "web". Note that "web" is a child of "lrapi."
For example, the abort function in the C syntax is:
However, working within VuGen in Java, the function is:
The web function, add_auto_header, in C syntax is:
In Java, it is:
There are, however, cases in which the user instantiates an object. Where this is done, the identifier of that instance must be used.
For example, in the Java syntax for the ftp protocol, the ftp object is instantiated explicitly in the script. That reference must be used for method invocation:
myFTPobj = objectHelper.CreateObject("LoadRunnerFtp.FtpApi.1");
"PATH=/pub/northanger/abbey.txt", ENDITEM , LAST);
When scripts are created with an external program, such as Microsoft Visual Studio.NET, methods are almost always invoked on user created objects. Constants are also members of those objects. In Microsoft Visual Basic.NET, for example:
Public Class VuserClass
' Initialize LR-API Interface
Dim lr As New LoadRunner.LrApi
' Initialize Web Interface
Dim lrWeb As New LoadRunner.WebApi
Initialize Utility Interface
Dim lrUtil As New LoadRunner.UtilityApi
Public Function Initialize() As Long
' Use LoadRunner.LrApi object, "lr"
"Note both constant and function object reference")
' Use LoadRunner.WebApi object, lrWeb
To use Java calls in a VuGen script without specifying the full class path, put an include statement at the beginning of the action. For example, to use web and utility functions, but this at the beginning of the action:
Without these statements, you will have to specify the parent class:
With the statements, you do not need the parent class:
The above also applies to predefined program constants. Some examples are:
Object Oriented Constants