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

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.

Transaction Functions in Loadrunner

Transaction Functions

There are different category of loadrunner functions available in Vugen. Below are the most important loadrunner functions used.

lr_end_sub_transaction :

  • lr_end_sub_transaction function marks the end of a sub-transaction.
  • 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_end_transaction_instance :

  • lr_end_transaction_instance function marks the end of a transaction instance 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_fail_trans_with_error :

  • lr_fail_trans_with_error function sets the default exit status to LR_FAIL for all open transactions with LR_AUTO in their lr_end_transaction statement and sends an error message.
  • The message is sent to the output window or log file.
  • It has LR_Fail, LR_Pass, LR_stop and LR_Auto Status.
  • You can manually set the status of the transaction according to your need.

lr_get_trans_instance_duration :

  • lr_get_trans_instance_duration function returns the duration of an open transaction instance in seconds until this point.
  • It was used to determine the total transaction time before the transaction has ended.
  • lr_get_trans_instance_duration returns values greater than zero only for open transactions.

lr_get_trans_instance_wasted_time :

  • lr_get_trans_instance_wasted_time function returns the Wasted Time of the specified transaction until this point.
  • lr_get_trans_instance_think_time function returns values greater than zero only for open transactions.

lr_get_transaction_duration :

  • lr_get_transaction_duration function returns the duration in seconds of the specified transaction to this point.
  • It will returns the duration including Wasted Time.

lr_get_transaction_think_time :

  • lr_get_transaction_think_time function returns the think time of the specified transaction until this point.
  • It returns values greater than zero only for open transactions.

lr_get_transaction_wasted_time :

  • lr_get_transaction_think_time function returns the think time of the specified transaction until this point.
  • It returns values greater than zero only for open transactions.

lr_resume_transaction :

  • lr_resume_transaction function resumes the reporting of transaction data within the script that was suspended by lr_stop_transaction.

lr_resume_transaction_instance :

  • lr_resume_transaction_instance function resumes the reporting of transaction data within the script that was suspended by lr_stop_transaction_instance.
  • If lr_resume_transaction_instance is not called, the final results reflect the statistics only until the call to lr_stop_transaction_instance.

lr_set_transaction_instance_status :

  • lr_set_transaction_instance_status function sets the status of the open transaction with the transaction handle trans_handle.
  • The handle was returned by lr_start_transaction_instance.

lr_set_transaction_status :

  • lr_set_transaction function creates a transaction, its duration, and status in a single call.
  • Use it where the business process you want to capture in a transaction does not consist of sequential steps, or where you may or may not want to create a transaction, depending on conditions that are known only during the test.

lr_set_transaction.

  • lr_set_transaction can also be used to report the duration of a failed transaction by saving the duration before the transaction fails with lr_get_transaction_duration then using lr_set_transaction to create a new transaction for reporting that time.
  • It creates and closes the transaction.

lr_set_transaction_status_by_name :

  • lr_set_transaction_status_by_name function sets the default status of the open transaction with name trans_name.
  • Transaction's lr_end_transaction statement must use automatic status assignment by passing LR_AUTO as its status parameter.
  • Transaction's status is defined in the status parameter of lr_end_transaction.

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.
  • A sub-transaction may also be a parent to a smaller sub–transaction.

lr_start_transaction :

  • lr_start_transaction function marks the beginning of a transaction.
  • 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_transaction_instance :

  • lr_start_transaction_instance function marks the beginning of a transaction instance. A
  • Transaction instance is an occurrence of a transaction with transaction_name.
  • Instances are identified by their handle which distinguishes them from other instances of the same transaction.
  • So the function returns the handle of the transaction instance which identifies the instance.

lr_stop_transaction :

  • lr_stop_transaction, statistics returned by the "get" Transaction Functions reflect only the data up to the call, until lr_resume_transaction is called.
  • The specified transaction must have been opened with lr_start_transaction.
  •  lr_resume_transaction is not called, the "get" functions and the final results reflect only the duration from the transaction start to the lr_stop_transaction call.
  • Thus, lr_stop_transaction and lr_resume_transaction can be used conditionally to collect information either about an entire transaction, or only the beginning.
  • To accomplish this, call lr_resume_transaction only if your condition is met.

lr_stop_transaction_instance :

  • lr_stop_transaction_instance, statistics returned by the "get" Transaction Functions reflect only the data up to the call, until lr_resume_transaction_instance is called.
  • The specified transaction instance must have been opened with lr_start_transaction_instance.
  • If lr_resume_transaction_instance is not called, the final results reflect the statistics only until the call to lr_stop_transaction_instance.
  • Therefore, lr_stop_transaction_instance and lr_resume_transaction_instance can be used to conditionally collect information about either the beginning, or all of the transaction.

lr_wasted_time :

  • lr_wasted_time allows you to subtract the time wasted on incidental or secondary actions from all open transactions.

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