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");

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.

String Functions Present in Loadrunner

String Functions

Below are the most important list of string functions 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" );

lr_save_var :

  • lr_save_var function assigns the specified variable length string to a parameter.
  • So the function is useful in Correlating Statements.
  • But to determine the value of the parameter, use the lr_eval_string function.
  • Do not:
    • save an input buffer that contains null or other binary data.
    • pass a value_len longer than the actual data.
  • Example : lr_save_var( lr_eval_string("{InName}"),  MAX_NAME_LEN, 0, "ShortName");  // Save the first four characters of "InName" to "ShortName"

lr_save_datetime :

  • lr_save_datetime function saves the current date and time, or the date and time with the specified offset into a parameter.
  • So resulting string will be truncated once it reaches MAX_DATETIME_LEN characters.
  • Example : lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");

lr _advance_param :

  • lr_advance_param function causes the script to use the next available value of the parameter.
  • But if you are running multiple iterations, you can specify in the parameter properties to advance automatically to the next value for each iteration.
  • So use this function within an iteration to advance to the next value.
  • Therefore the function is not recorded—you insert it manually into your script.
  • Example : lr_advance_param("Param1");

lr _decrypt :

  • lr_decrypt function unmasks an encoded string. This function is generated during recording to encode passwords.
  • VuGen records the actual password but displays an encoded version of the password within the lr_decrypt function.
  • Example :  txtPassword = lr.decrypt("38620da61ca1093e7aa7ec");

lr_eval_string_ext :

  • lr_eval_string_ext function evaluates in_str by replacing parameters with their string value.
  • It creates a buffer containing the expanded string and sets out_str to point to that buffer.
  • But also assigns the length of the buffer to out_len. Use this function in conjunction with lr_eval_string_ext_free in preference to lr_eval_string when evaluating strings in a loop.
  • Using lr_eval_string in a loop uses more memory.
  • Example : lr_eval_string_ext ("{Param1}", 8, &newParam,  &prmLen, 0, 0,-1);

lr_eval_string_ext_free :

  • lr_eval_string_ext_free function frees the memory allocated by lr_eval_string_ext.
  • Example : lr_eval_string_ext ("{Param1}", 8, &newParam, &prmLen, 0, 0,-1);

lr_save_searched_string :

  • lr_save_searched_string function searches for string search_string inside string or character array buffer, and finds the nth occurrence of search_string, where n is occurrence plus 1.
  • So the sub-string to be saved starts at offset after the end of the nth occurrence of search_string, and has length string_len.
  • Example : lr_save_searched_string(data_1, olen, 0, "SCertRep", 9, 16, "cert1");

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