Sunday, January 1, 2017

How to Convert a Web - HTTP/HTML Vuser Script into a Java Vuser Script in Load Runner?

VuGen had an advantage  that enables you to convert a Web - HTTP/HTML Vuser script into a Java Vuser script. This also allows you to create a hybrid Vuser script for both Web and Java.

Steps for the Conversion:
  1. Create an empty Java Vuser script and save it with your desired name.
  2. Create an empty Web (HTML/HTTP) Vuser script and save it with your desired name.
  3. Record a session into the Web (HTML/HTTP) Vuser script.
  4. Replay the Web (HTML/HTTP) Vuser script. When it replays successfully, cut and paste the entire script into a text editor and save it as a text file (.txt). 
  5. In the text file, modify any parameter braces from the Web type, "{ }" to the Java type, "< >".
  6. Open a DOS command window and go to the / dat folder.
Type the below command
\bin\sed -f web_to_java.sed filename > outputfilename

filename- Full path and filename of the text file you saved earlier
outputfilename -The full path and filename of the output file.

Open the output file, and copy its contents into your Java Vuser script action section at the desired location.If you are pasting the contents into an empty custom Java template (Java Vuser type), modify the line containing public int action() as follows:
public int action() throws Throwable
This change is done automatically for recorded Java users (RMI and CORBA).

Parameterize and correlate the Vuser script as you would with an ordinary Java script, and run the script.