How to Manually Insert Java Methods

You can use pre-defined Java packages within a Vuser script. The packages can be included in specific archive files or in the archive files contained in designated folders. You use the "Insert Java Function" dialog box to add the functions to your Vuser script. Packages, classes, methods, and other objects are represented by various icons in the "Insert Java Function" dialog box. For a list of icons, see Java Icon Reference List.

You can customize the function generation settings by modifying the recording options. For more information, see General > Script Recording Options.

To Insert Java Functions:

  1. Click within your script at the desired point of insertion.

  2. Click Java Function in the toolbar. The Insert Java Function dialog box opens. Under Locations, VuGen lists the paths and archives defined in the CLASSPATH environment variable.

  3. To add a path, click Select Folder and then locate and highlight the required folder. To add an archive (jar or zip), click Select Library and then locate and highlight one or more archive files. When you select a folder or an archive file, VuGen lists it in the Locations box.

  4. Repeat step 3 for each path or archive you want to add.

  5. Select or clear the check boxes to the left of each item in the Locations list. If an item is selected, its members will be listed in the Packages list below.

  6. Click Packages to close the Locations area and view the available packages.

  7. Click the arrows to the left of each item in the navigator, to expand or collapse the trees.

  8. Select an object and click Insert. VuGen inserts the object at the location of the cursor in the script. To paste all the methods of a class into your script, select the class and click Insert.

  9. Repeat the previous step for all of the desired methods or classes, and then click Close.

    Note: When you close the "Insert Java Function" dialog box, VuGen gives you the option to add the newly added locations to the Classpath list in the Java Environment runtime settings.

  10. Modify the method parameter. If the script generation setting DefaultValues is set to true, you can use the default values inserted by VuGen. If DefaultValues is set to false, you must add parameters for all methods you insert into the script.

  11. In addition, modify any return values. For example, if your script generated the following statement "(String)=LavaVersion.getVersionId();", replace (String) with a string type variable.

  12. Add any necessary statements to your script, such as imports or Java-specific functions, from the Function Reference. For details, see Java Vuser Protocol.

  13. Save the script and run it from VuGen.

Back to top