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

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.