LoadRunner Tutorials

HP LoadRunner Tutorial

Training Summary

LoadRunner is the product from Micro Focus Company currently earlier it was with HP Team. Loadrunner is the most widely used tool for performance testing as it support multiple protocol and also its user friendly compared to any other tools in the market.

Syllabus


Tutorial  -> Architecture of Loadrunner and Introduction to Loadrunner


Tutorial -> Recording Options in Loadrunner.


Tutorial -> How to record web script in Loadrunner.


Tutorial -> How to do Parametrization in Loadrunner.


Tutorial -> How to do Correlation in Loadrunner.


Tutorial -> Loadrunner Functions


Tutorial -> Interview Questions


Tutorial-> Quiz to test your understanding on Loadrunner.


 

How to call C Function in Ajax TrueClient?

Call C Function in Ajax TrueClient Script

C Function in ajax trueclient is used to write your own custom code in the C-function.c file. Then call the function in your script to execute the custom code.

We will see how to call the C function from the ajax trueclient script step by step.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow or you can add the functions before itself.

Add Ajax TrueClient VTS functions : Script

Click Here to know how to record the script in trueclient

Step 2:

  • Drag and drop the Evaluate Java script into the trueclient panel from the miscellaneous section.
  • And click on the js option present in the Evaluate Java script option.
  • Once you click on the js option, the working area will be displayed.

Add Ajax TrueClient VTS functions : Java script

Step 3 :

  • Call the C function using the TC.evalC function.
  • Syntax : TC.evalC(Functionname,timeout);
    • Functionname : Name of the function which you will be calling from the C Function file.
    • timeout : You can specific how long you want the function to wait for completing it.
  • So the function looks like this TC.evalC("Demo",20);  after you entering the required field data.
  • And also  we will add the message so that we can see the message in the output panel once the function is successfully called.
  • After writing the function click on OK button.

Click Here to know more about the Ajax TrueClient functions.

Step 4 :

  • Now go to the C-function file and select the file.
  • Write your custom code in the C-Function file.
  • Save the script.
  • Close the Developer mode of the trueclient script.

Step 5 :

  • Once the developer mode is closed and the script view is enabled.
  • Save the script again and click on Run button.
  • So the script will be executed end to end without any error message.
  • Go to the output panel, you will see the message when the function is called and the custom code as well.
  • Below is the example how it will be displayed in the output panel.

 

How to add transactions in Ajax TrueClient?

Adding Transaction in Ajax TrueClient Script.

There are two ways to add the transaction to the script in ajax trueclient script. We will see both the ways step by step.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow , for which the transaction should be added.

Ajax TrueClient Adding Transactions

Click Here to see how to record the script in Ajax TrueClient.

Step 2 :

  • Once you have recorded the flow completely. Then one can add the transaction to the scripts.
  • So select the step in the flow for which you want to add the transactions.
  • Right Click on the selected step. Then select the star transaction option.

Step 3 :

  • Once you click in Start Transaction link.
  • Transaction window will be displayed.
  • Enter the Transaction name in that and click on OK button.

Step 4 :

  • And again select the step in the flow for which you want to end the transactions.
  • Right Click on the selected step. Then select the End Transaction option.
  • You will see the Transaction name which you have added to start the transaction.
  • Click on the Transaction Name. (Right Click -> End Transaction -> Demo_Transcation_01).
  • So the transaction will be added the script.

Step 5 :

  • We have another way to add the transaction to the script.
  • Transaction icon on top of the panel will be displayed. Click on that icon.
  • Transaction Editor Window will be displayed.

Step 6:

  • So there will be a + plus button in the transaction editor window. Click on that icon.
  • We will find three section in that editor.
    • General - > Name : 
      • Enter the name of the transaction in that field.
    • Start Point :
      • Step : Select the Step from the drop down, where you want to add the start transaction.
      • Event : And also the select the event from the drop down.
    • End Point : 
      • Step : Select the Step from the drop down, where you want to add the end transaction in the flow.
      • Event : And also the select the event from the drop down.
  • Click on OK button.

Step 7 :

  • Once you have click OK on the editor.
  • Then the transaction will be added to the script.
  • Transaction will be added to the script. Save the script and close the developer mode.
  • So Click on Run button and the script will give you the result as shown below.(If the transaction result are not displayed in the reply window then go and change the setting as Tools-> Options ->Scrpting -> reply (Select "Collect reply Statistics ") )

How to add VTS functions in Ajax TrueClient script

Adding Ajax TrueClient VTS functions to the Script

We will see how to add the vts function to the trueclient script step by step.

Step 1 :

  • Launch the trueclient protocol in the Vugen.
  • And click on Develop script option in the script.
  • And record the flow or you can add the functions before itself.

Add Ajax TrueClient VTS functions : Script

Click Here to know how to record the script in trueclient

Step 2:

  • Drag and drop the Evaluate Java script into the trueclient panel from the miscellaneous section.
  • And click on the js option present in the Evaluate Java script option.
  • Once you click on the js option, the working area will be displayed.

Add Ajax TrueClient VTS functions : Java script

Step 3 :

  • You should be knowing the VTS server name and port number. If not then fellow the steps.
    • Launch the VTS Server where it has installed..
    • And the copy the server name of the VTS. Here the VTS server name is localhost.
    • And also copy the port number which is used to communicate with the server. Port number is 8888.

Add Ajax TrueClient VTS functions: VTS Server

  • So if you know the server and port number of the VTS then you can skip to step number 4.

Step 4 :

  • And the working area will be displayed once the js option is clicked.
  • Add the vts connect function which is used to connect to the VTS server.
    • TC.vtcConnect(serverName, port, vtsName);
    • serverName: which we copied from the VTS server.
    • Port : Number which is used to communicate to the server which we copied in the last step.
    • vtsName: It the alias name which will be used to add,get,clear or disconnect from the VTS server.
  • So the function will be as below
    • TC.vtcConnect("localhost", 8888, "vtsdemo");
  • But to verify the connection let add a verifying logic to check if the connection is successful to the VTS server or not.
  • So click on OK after entering the details.

 

Step 5:

  • Now add Evaluate Java script again for sending the data to the VTS server.
  • And add the below code in the editor and click on ok button.
  • TC.vtcAddCell("P_Address", "1665656 Road", "vtsdemo");

Step 6 :

  • And again add one more Evaluate Java script from the miscellaneous section for disconnecting from the VTS server.
  • Add the vts disconnect function which is used to disconnect from the VTS server.
    • TC.vtcDisconnect(vtsName);
    • vtsName: The same alias name which will be used during connecting to the VTS server.
  • So the function will be as below
    • TC.vtcDisconnect("vtsdemo");
  • But to verify the connection let add a verifying logic to check if the connection is successful disconnected the VTS server or not.
  • Click on OK after entering the details.

Step 7 :

  • And save the script and click on run button.
  • You will see count of data sent to the VTS on the Refresh button.
  • So once you see the count click on Refresh button and the data will reflect which is sent to the VTS server from the script.
  • But the output message will not be displayed in the developer mode. Check next step to see the output message.

Step 8 :

  • So once the script is running end to end without any error message.
  • Close the developer mode of the trueclient.
  • Save the script again and click on run button.
  • So you will see the message on the output panel for connecting and disconnecting from the server.
  • And also the data will be entered in the VTS server.

Top10 Ajax TrueClient Functions Present in Loadrunner

Top 10 Ajax TrueClient Functions

Below are the list of important ajax trueclient functions present in loadrunner.

Utils.clearCookies :

  • One can clear the cache of browser for each a single Vuser.
  • So the content of the whole cache simulator is unaffected.
  • But the function is not supported in the Chromium browser.
  • But it is supported in IE and Firebox browser.
  • Syntax : Utils.clearCookies();
  • Example : Utils.clearCookies();

Utils.clearCookies :

  • Removes all cookies currently stored by the Vuser.
  • So all cookies for each iteration will be cleared.
  • Syntax : Utils.clearCookies();

Utils.addAutoHeader :

  • One can add the custom header to the script.
  • So you can use this function to send the header value to the script.
  • Syntax : Utils.addAutoHeader(header, value, merge);
    • header. (String) name of the header to be added.
    • value. (String) value of the header to be added.
    • merge. (Boolean) True value indicates to merge the value with an existing header by the same name, false indicates to overwrite it.
  • Example : Utils.addAutoHeader("someCustomHeader", "someValue", true);

Utils.cleanupAutoHeaders :

  • So it removes all HTTP headers in the script.
  • And also stops adding HTTP headers to every consecutive HTTP request following this function call.
  • Syntax : Utils.cleanupAutoHeaders();

TC.setParam :

  • It is used too save the string value to a parameter or to a other value.
  • So the equivalent function used in web script is : lr_eval_string.
  • Syntax : TC.setParam(name, value);
    • name. (String) The name of the parameter in which to save the value.
    • value. (String) The parameter value.
  • Example: TC.setParam("myparam", "paramVal");

TC.outputMessage :

  • It is used to display the message on the output panel of the Vugen.
  • But if your running the script in performance center or controller it will wrote the message to the Vuser logs.
  • One can also append the parameter values in the message using +.
  • So the equivalent  function used in web script is : lr_output_message.
  • Syntax : TC.outputMessage(text);
    • text. (String) The message text.
  • Example: TC.outputMessage("My output message");

TC.getParam ;

  • It will returns the value of the specified parameter from the file.
  • So you can use that parameter in the script.
  • Syntax :  TC.getParam(name);
    • name. (String) The parameter name.
  • Example : TC.getParam("Filename");

TC.log :

  • It is also used to send the message to the Vuser log file.
  • But it will not display the message in panel during the test execution in the controller or performance center.
  • So you can send the status of the message using the available level.
  • Syntax : TC.log(text, level);
    • text. (String) The message.
    • level. Optional argument. One of the following:
      • "Error"
      • "Warning"
      • "Standard" (default value)
      • "Extended"
      • "Status"
      • "Status_msg"
  • Example: TC.log("my warning", "Warning");

TC.vtcConnect :

  • It is used to established the connection from the scripts to the VTS server.
  • So it will open the connection from the script to VTS server and the connection will be open until it is disconnected.
  • So the equipment function used in web script  is  : vtc_connect.
  • Syntax : TC.vtcConnect(serverName, port, vtsName);
    • serverName. (String) Either the IP or server name.
    • port. (Integer) The port number
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcConnect("MyServer", 8888, "MyVts");

TC.vtcAddCell :

  • Used to add or send a value to a column specified.
  • So the values will be added to the end of the column.
  • But if the column name is not present in the VTS server, then it will create the column name and add the value.
  • So the equipment function used in web script  is  : lrvtc_send_message.
  • Syntax : TC.vtcAddCell(colName, value, vtsName);
    • colName. (String) The name of the column.
    • value. (String) The value as a string.
    • vtsName. (String) The alias of the VTS server.
  • Example :  TC.vtcAddCell("P_Address", "1665656 Road", "VTS_Name");

TC.vtcPopCell :

  • It will return the first row value of the column specified.
  • But it will delete the value from the cell.
  • So the equivalent method in web script is : lrvtc_retrieve_message.
  • Syntax : TC.vtcPopCell(colName, vtsName);
    • colName .(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcPopCell("MyColumn","MyVts"); 

TC.vtcClearColumn :

  • It will clear all the values in the column.
  • So the equivalent method in LoadRunner: lrvtc_clear_column.
  • Syntax : TC.vtcClearColumn(colName, vtsName);
    • colName.(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcClearColumn("MyColumn","MyVts");

TC.vtcDisconnect :

  • It is used to disconnect the VTS connection from the server.
  • So the equivalent method in LoadRunner: lrvtc_disconnect.
  • Syntax : TC.vtcDisconnect(vtsName);
  • Example : TC.vtcDisconnect( "MyVts");

Ajax TrueClient Vuser Functions

Ajax TrueClient Vuser Functions

Below are the list of Vuser functions present in Ajax TrueClient Functions.

TC.setParam :

  • It is used too save the string value to a parameter or to a other value.
  • So the equivalent function used in web script is : lr_eval_string.
  • Syntax : TC.setParam(name, value);
    • name. (String) The name of the parameter in which to save the value.
    • value. (String) The parameter value.
  • Example: TC.setParam("myparam", "paramVal");

TC.outputMessage :

  • It is used to display the message on the output panel of the Vugen.
  • But if your running the script in performance center or controller it will wrote the message to the Vuser logs.
  • One can also append the parameter values in the message using +.
  • So the equivalent  function used in web script is : lr_output_message.
  • Syntax : TC.outputMessage(text);
    • text. (String) The message text.
  • Example: TC.outputMessage("My output message");

TC.log :

  • It is also used to send the message to the Vuser log file.
  • But it will not display the message in panel during the test execution in the controller or performance center.
  • So you can send the status of the message using the available level.
  • Syntax : TC.log(text, level);
    • text. (String) The message.
    • level. Optional argument. One of the following:
      • "Error"
      • "Warning"
      • "Standard" (default value)
      • "Extended"
      • "Status"
      • "Status_msg"
  • Example: TC.log("my warning", "Warning");

evalXPath :

  • Used to save to the path of object on the page.
  • And also you can use the value to write your logic.
  • Syntax : evalXPath(xpath);
    • xpath. (String) The xpath query.
  • Example : evalXPath("//a[text()=\" New Mercury Tours \"]");

TC.evalC :

  • It is mainly used to call the C function from the trueclient script.
  • Function that is defined in the C-functions.c file.
  • Syntax : TC.evalC(funcname, functimeout).
    • funcname. (String) The function name.
    • functimeout. (Number) The maximum expected runtime, in seconds, of the function called by the step.
  • So one can also specify the limit that function should take to complete.
  • Example : TC.evalC("myFunc", 20);

Syntax :

TC.vuserStatusMessage :

  • It is mainly used to indicates which Vuser is handling the particular script.
  • So you can use this function to check which user is executing the script.
  • Syntax : TC.vuserStatusMessage(text);
    • text. (String) Any text string.
  • Example : TC.vuserStatusMessage("FlightStatus");

TC.getParam ;

  • It will returns the value of the specified parameter from the file.
  • So you can use that parameter in the script.
  • Syntax :  TC.getParam(name);
    • name. (String) The parameter name.
  • Example : TC.getParam("Filename");

TC.advanceParam :

  • It is used to specify parameter to the pick the next value in the file.
  • So this is mainly used for the parameter of type file or unique number.
  • But the equivalent  function used in web script is : lr_advance_param.
  • Syntax : TC.advanceParam(name);
    • name. (String) The name of the parameter to advance.
  • Example : TC.advanceParam("multi_row_param");

Ajax TrueClient VTS Functions

Ajax TrueClient VTS Functions

Below are the list of Ajax TrueClient VTS Functions present in loadrunner and there examples.

TC.vtcConnect :

  • It is used to established the connection from the scripts to the VTS server.
  • So it will open the connection from the script to VTS server and the connection will be open until it is disconnected.
  • Equipment function used in web script  is  : vtc_connect.
  • Syntax : TC.vtcConnect(serverName, port, vtsName);
    • serverName. (String) Either the IP or server name.
    • port. (Integer) The port number
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcConnect("MyServer", 8888, "MyVts");

TC.vtcAddCell :

  • Used to add or send a value to a column specified.
  • So the values will be added to the end of the column.
  • But if the column name is not present in the VTS server, then it will create the column name and add the value.
  • Equipment function used in web script  is  : lrvtc_send_message.
  • Syntax : TC.vtcAddCell(colName, value, vtsName);
    • colName. (String) The name of the column.
    • value. (String) The value as a string.
    • vtsName. (String) The alias of the VTS server.
  • Example :  TC.vtcAddCell("P_Address", "1665656 Road", "VTS_Name");

TC.vtcAddCells :

  • It is used to add multiple values into the VTS using this function.
  • So the values will be added to the end of the specified column.
  • But if the column name is not present in the VTS server, then it will create the column name and add the value.
  • Equipment function used in web script  is  : vtc_send_row1.
  • Syntax : TC.vtcAddCells(colNames, values, option, vtsName);
    • ColNames. (String) Column names delimited by a semi-colon.
    • values. (String) The values as a string delimited by a semi-colon.
    • option. (Integer) Define how the values are added.
      • 0. Add as same row in all columns based on the column with the highest row count. The created row will be n+1 for all columns.
      • 1. Add as stack - last row in every column.
      • 2. Add as unique stack - last row in every column only if the value is unique in the column.
  • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcAddCells( "MyColumn1;MyColumn2;MyColumn2", "MyValue1;MyValue2;MyValue3", 0, "MyVts");

TC.vtcGetCell :

  • It will return the first row value of the column specified.
  • But it will not delete the value from the cell.
  • It will just copy the values from the column.
  • Equivalent method in web script is : lrvtc_query_column.
  • Syntax : TC.vtcGetCell(colName, rowIndex, vtsName);
    • colName .(String) The name of the column.
    • rowIndex. (Integer) The index number of the field as an integer. 1 is the first field in the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcGetCell("MyColumn",1,"MyVts");

TC.vtcPopCell :

  • It will return the first row value of the column specified.
  • But it will delete the value from the cell.
  • Equivalent method in web script is : lrvtc_retrieve_message.
  • Syntax : TC.vtcPopCell(colName, vtsName);
    • colName .(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcPopCell("MyColumn","MyVts"); 

TC.vtcClearCell :

  • It is used to clear the value in the column.
  • By default it will clear the first value in the columns. But you can specific the cell number also which one you want to delete.
  • Equivalent method in LoadRunner: lrvtc_clear_message.
  • Synatax : TC.vtcClearCell(colName, rowIndex, vtsName);
    • colName. (String) The name of the column.
    • rowIndex. (Integer) The index number of the field as an integer. 1 is the first field in the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcClearCell("MyColumn",1,"MyVts");

TC.vtcClearColumn :

  • It will clear all the values in the column.
  • Equivalent method in LoadRunner: lrvtc_clear_column.
  • Syntax : TC.vtcClearColumn(colName, vtsName);
    • colName.(String) The name of the column.
    • vtsName. (String) The alias of the VTS server.
  • Example : TC.vtcClearColumn("MyColumn","MyVts");

TC.vtcDisconnect :

  • It is used to disconnect the VTS connection from the server.
  • Equivalent method in LoadRunner: lrvtc_disconnect.
  • Syntax : TC.vtcDisconnect(vtsName);
  • Example : TC.vtcDisconnect( "MyVts");

Top 10 Loadrunner Functions

Top 10 LoadRunner Functions :

Below are the most 10 important loadrunner functions present in loadrunner.

lr_end_sub_transaction :

  • lr_end_sub_transaction function marks the end of a sub-transaction.
  • So insert these functions immediately before and after the sub-transaction steps.

lr_end_transaction :

  • lr_end_transaction function marks the end of a transaction and records the amount of time it took to perform the transaction.
  • It has LR_Fail, LR_Pass, LR_stop and LR_Auto Status.
  • So you can manually set the status of the transaction according to your need.

lr_start_transaction :

  • lr_start_transaction function marks the beginning of a transaction.
  • So the transactions can be nested, but each lr_start_transaction statement must be associated with an lr_end_transaction statement or it will be interpreted as an illegal command.

lr_start_sub_transaction :

  • lr_start_sub_transaction function marks the beginning of a sub-transaction.
  • Sub-transactions are used for isolating parts of a business process.
  • Multiple sub-transactions can be nested within a parent transaction.
  • But a sub-transaction may also be a parent to a smaller sub–transaction.

Click Here to see all the transaction function present in loadrunner.

lr_eval_string :

  • lr_eval_string function returns the input string after evaluating any embedded parameters.
  • So if the string argument contains only a parameter, the function returns the current value of the parameter.
  • Example : lr_save_int(47, "searchCount");

lr_save_string :

  • lr_save_string function assigns the specified null-terminated string to a parameter.
  • But the functions is useful in correlating queries.
  • Example : lr.save_string("John Doe" , "Student" );
Click Here to see all the string function present in loadrunner.

lr_error_message :

  • lr_error_message function sends an error message to product output windows log files, and other test report summaries.
  • Example : lr_error_message("Error: %s", "Unable to login to secure computing");

lr_log_message :

  • lr_log_message function sends a message to the Vuser or agent log file (depending on the application), and not to the output window.
  • So you can use this function for debugging by sending error or other informational messages to the log file.
  • But in a standalone program such as VuGen, lr_log_message sends the message to the viewer and output.txt.
  • Example : lr_log_message ("login failed: %s", abort);}

lr_output_message :

  • lr_output_message function sends a message with the script section and line number to output windows, log files, and other test report summaries.
  • Example : lr_output_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );

Click Here to see all the message function present in loadrunner.

lr_think_time :

  • lr_think_time allows you to pause test execution during a run.
  • But this is especially useful in simulating think time, the time a real user pauses to think between actions.
  • Example : lr.think_time(1);

Click Here to see all the run time function present in loadrunner.

Run-Time Functions Present in Loadrunner

Run-Time Functions

Below are the most important list of Run Time functions present in load runner.

lr_load_dll :

  • lr_load_dll function loads a DLL (Windows) or shared object (Linux) allowing you to call an external function when replaying using the C interpreter.
  • Once you load the DLL, you can call any function defined in the DLL, without having to declare it.
  • On Windows platforms, except for the SAP GUI protocol, if you do not specify a path, lr_load_dll searches for the DLL using the standard sequence used by the C++ function, LoadLibrary.
  • Example : lr_load_dll("user32.dll");

lr_peek_events :

  • lr_peek_events function suspends the Vuser script run and checks for events before resuming.
    • Scripts written in C language perform this check internally. Therefore, there is no need to use the lr_peek_events function.
    • Scripts written in Java do not perform this check internally. Therefore, insert this function into your Vuser script at the point at which you want the Vuser to pause.
  • Example : lr_peek_events();

lr_think_time :

  • lr_think_time allows you to pause test execution during a run.
  • This is especially useful in simulating think time, the time a real user pauses to think between actions.
  • Example : lr.think_time(1);

lr_rendezvous :

  • lr_rendezvous function creates a rendezvous point in a Vuser script.
  • When this statement is executed, the Vuser program stops and waits for permission to continue.
  • This function can only be used in an action section, and not in vuser_init or vuser_end.
  • Example : lr.rendezvous("QueryRendz");

lr_continue_on_error :

  • lr_continue_on_error function specifies how to handle errors.
  • You can choose to continue running if an error occurs, or to abort the run execution.
  • To continue script execution even when errors occur, select the Continue on Error check box in VuGen's Runtime Settings.
  • Example : lr_continue_on_error(1);

lr_abort :

  • lr_abort function aborts the execution of a script .
  • It stops the execution of the Actions section, executes the vuser_end section, and ends the execution.
  • This function is useful when you need to manually abort a run as a result of a specific error condition.
  • When you end a run using this function, the status is "Stopped."
  • Example : lr.abort( );

lr.exit :

  • lr_exit function allows you to exit from the script run during execution.
  • Example : lr.exit(lr.EXIT_VUSER, lr.FAIL);

Click Here to see all the string function present in loadrunner.

Message Functions Present in Loadrunner

Message Functions

Below are the most important list of message functions present in loadrunner.

lr_debug_message :

  • lr_debug_message function sends a debug message when the specified message level is active.
  • If the specified message level is not active, a message is not issued.
  • So you can set the active message level to MSG_CLASS_BRIEF_LOG or MSG_CLASS_EXTENDED_LOG from the user interface or by using lr_set_debug_message.
  • But to determine the current level, use lr_get_debug_message.
  • Example : lr_debug_message(LR_MSG_CLASS_RESULT_DATA | LR_MSG_CLASS_PARAMETERS, "Operation failed.");

lr_error_message :

  • lr_error_message function sends an error message to product output windows log files, and other test report summaries.
  • Example : lr_error_message("Error: %s", "Unable to login to secure computing");

lr_get_debug_message :

  • lr_get_debug_message function returns the current log run-time settings .
  • But the settings determine what information is sent output.
  • The log settings are specified with the run-time settings dialog, or by using the lr_set_debug_message function.
  • Example : msg_level=lr_get_debug_message( );

lr_log_message :

  • lr_log_message function sends a message to the Vuser or agent log file (depending on the application), and not to the output window.
  • So you can use this function for debugging by sending error or other informational messages to the log file.
  • But in a standalone program such as VuGen, lr_log_message sends the message to the viewer and output.txt.
  • Example : lr_log_message ("login failed: %s", abort);}

lr_output_message :

  • lr_output_message function sends a message with the script section and line number to output windows, log files, and other test report summaries.
  • Example : lr_output_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );

lr_set_debug_message :

  • lr_set_debug_message function changes the debug message level bitmap.
  • The message level is initially set in the script's Run-time Settings dialog box.
  • lr_set_debug_message changes the message level from the current value.
  • So, the message level in effect is the result of the Run-time Settings and all previous calls to lr_set_debug_message.
  • Example : lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG | LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_OFF );

lr_vuser_status_message :

  • lr_vuser_status_message function sends a string to the Status area of the Controller.
  • But it will also sends the string to the Vuser log. When run from VuGen, the message is sent to output.txt.
  • Example : lr_vuser_status_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );

lr_message :

  • lr_message function sends a message to the log file and output window.
  • When run in VuGen, the output file is output.txt.
  • So use the lr_log_message instead of this function to send the message only to the log file.
  • Example : lr_message ("login failed: %s", abort);}

Click Here to see all the transaction function present in loadrunner.