Once you record a flow in Load runner, the next step is to enhance the script. Enhancing the script requires all the understanding of Load runner as this is the most critical phase of it.
You need to have understanding about all the functions that are present in your script while recording. To enhance the script for actual performance testing you require debugging the script to make it work for different set of input data.
In this blog, I am listing all the load runner functions which can be used across all the protocols and they start with lr_. I have added explanation for most used functions. Hope this helps you for your scripting or for revision for your test or interview.
You need to have understanding about all the functions that are present in your script while recording. To enhance the script for actual performance testing you require debugging the script to make it work for different set of input data.
In this blog, I am listing all the load runner functions which can be used across all the protocols and they start with lr_. I have added explanation for most used functions. Hope this helps you for your scripting or for revision for your test or interview.
1. lr_abort():
Aborts the execution of a script
lr_abort();
2. lr_advance_param
Advances to the next available parameter value.
lr_advance_param("Param1"); //where Param1 is the parameter name
3. lr_continue_on_error
Specifies an error handling method.
lr_continue_on_error(1);
0- LR_ON_ERROR_NO_OPTIONS
1- LR_ON_ERROR_CONTINUE
2- LR_ON_ERROR_SKIP_TO_NEXT_ACTION
3- LR_ON_ERROR_SKIP_TO_NEXT_ITERATION
4- LR_ON_ERROR_END_VUSER
4. lr_convert_string_encoding
Converts a string to a different encoding.
lr_convert_string_encoding("Hello world",LR_ENC_SYSTEM_LOCALE,LR_ENC_UNICODE,"stringInUnicode");
where Hello world - The string to convert
LR_ENC_SYSTEM_LOCALE - The encoding of the sourceString
LR_ENC_UNICODE - The encoding to convert of the string saved in parameter paramName
stringInUnicode -The name of the parameter in which the destination string will be saved
5. lr_convert_double_to_double
It converts the string representation of a double to several other string representations
6. lr_convert_double_to_integer
It converts the string representation of a double to the string representation of an int
7. lr_db_dataset_action
Performs an action on a dataset.
lr_db_dataset_action("StepName=<step_name>", "DatasetName=<dataset_name>", "Action=<action>", LAST );
8. lr_db_connect
Connects to a database.
lr_db_connect("StepName", "ConnectionString=<connection_string>", "ConnectionName=<connection_name>", "ConnectionType=<connection_type>", LAST );
9. lr_db_disconnect
Disconnects from a database.
lr_db_disconnect("StepName=<step_name>", "ConnectionName=<connection_name>", LAST );
10. lr_db_executeSQLStatement
Submits an SQL statement to a database.
lr_db_executeSQLStatement("StepName=<step_name>", "ConnectionName=<connection_name>", "SQLStatement=<statement>", ["DatasetName=<dataset_name>",] LAST );
11. lr_checkpoint
Validates the value of a parameter against an expected value (checkpoint).
lr_checkpoint( "StepName=<step_name>", "ActualValue={<input_param>}", "Compare=<operator>", "ExpectedValue={<checkpoint>}", "StopOnValidationError=<error_code>", LAST );
12. lr_db_getValue
Retrieves a value from a dataset.
lr_db_getValue( "StepName=<step_name>", "DatasetName=<dataset_name>", "Column=<column>", "Row=<row>", "OutParam=<output_parm>", LAST );
13. lr_debug_message
14. lr_decrypt
Decrypts an encoded string
lr_decrypt("38620da61ca1093e7aa7ec");
15. lr_disable_ip_spoofing
16. lr_enable_ip_spoofing
17. lr_end_cross_vuser_transaction
Marks the completion in this vuser of a transaction started by a different vuser.
18. lr_end_sub_transaction
Marks the end of a sub-transaction.
lr_end_sub_transaction("electrical_purchases", LR_FAIL);
where electrical_purchases is sub transaction name
LR_FAIL is transaction status
19. lr_end_transaction( char *transaction_name, int status)
Marks the end of a transaction.
lr_end_transaction("deposit", LR_FAIL);
where deposit is transaction name
LR_FAIL/LR_PASS are transaction status
20. lr_end_transaction_instance
21. lr_end_timer
22. lr_error_message
This function is used when you want to output an error to different log files in Loadrunner. This function will send to output file even though logging is disabled as this is error log.
23. lr_eval_string
Returns the string argument after evaluating embedded parameters.It evaluates a parameter and after evaluating the parameter it replaces the parameter with its current value.
lr_eval_string("The row count is: {row_cnt}");
where row_cnt is The string to evaluate
24. lr_eval_string_ext
Creates a buffer and assigns it the input string after evaluating embedded parameters.
25. lr_eval_string_ext_free
Frees the buffer allocated by lr_eval_string_ext.
Note: lr_eval_string allocates memory internally. The memory is freed at the end of each iteration. If you evaluate a parameter or parameters in a loop, conserve memory by not using lr_eval_string. Instead, use lr_eval_string_extand free the memory in each loop iteration with lr_eval_string_ext_free.
26. lr_exit
Exits from the script, action, or iteration.
lr_exit(LR_EXIT_VUSER, LR_FAIL);
where LR_EXIT_VUSER specifies how the script continues after the call to lr_exit.
27. lr_fail_trans_with_error
28. lr_get_attrib_double
29. lr_get_attrib_long
30. lr_get_attrib_string
It retrieves the name of the host string value from the mdrv command line string that was used to run the script
31. lr_get_debug_message
Returns the current message logging settings.
lr_get_debug_message function retrieves the runtime logging settings, performs a bitwise operation, and sends an appropriate message
msg_level=lr_get_debug_message( );
32. lr_get_host_name
Returns the name of the host executing the script.
my_host = lr_get_host_name( );
33. lr_get_master_host_name
34. lr_get_transaction_duration
35. lr_get_transaction_status
36. lr_get_trans_instance_duration
37. lr_get_trans_instance_status
38. lr_get_trans_instance_think_time
39. lr_get_trans_instance_wasted_time
40. lr_get_transaction_think_time
41. lr_get_transaction_wasted_time
42. lr_get_vuser_ip
43. lr_load_dll
44. lr_log_message
45. lr_message
46. lr_output_message
Sends a message to log files, output windows, and other test report summaries.
lr_output_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );
47. lr_next_row
48. lr_param_increment
49. lr_param_sprintf
lr_param_sprintf("variable","%02x",strlen(lr_eval_string("{var}")));
Gets the length of var and converts it into binary and stores in variable
50. lr_param_unique
51. lr_paramarr_idx
52. lr_paramarr_len
53. lr_paramarr_random
54. lr_peek_events
55. lr_rendezvous
Creates a rendezvous point in the Vuser script.
lr_rendezvous("Meeting");
do_transaction(); /* application dependent transaction */
56. lr_rendezvous_ex
Creates a rendezvous point in the Vuser script.
57. lr_resume_transaction
58. lr_resume_transaction_instance
59. lr_save_datetime
Assigns the current date and time to a parameter.
lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");
lr_output_message(lr_eval_string("{next}"));
If today is January 7th, 1999, these lines will return the message: Tomorrow is January 08 1999.
60. lr_save_int
Saves an integer to a parameter.
int num;
num = 5;
lr_save_int(num * 2, "param1");
The value of param1 is now "10".
61. lr_save_param_regexp
62. lr_save_searched_string
63. lr_save_string
64. lr_save_timestamp
Saves the current time in a parameter as a time-stamp.
lr_save_timestamp("param", LAST );
65. lr_save_var
66. lr_set_debug_message
67. lr_set_transaction
68. lr_set_transaction_instance_status
69. lr_set_transaction_status
70. lr_set_transaction_status_by_name
71. lr_start_cross_vuser_transaction
72. lr_start_transaction( char *transaction_name );
Marks the beginning of a transaction
lr_start_transaction("deposit");
73. lr_start_transaction_instance
74. lr_start_sub_transaction
75. lr_stop_transaction
Freezes reporting of transaction data.
76. lr_stop_transaction_instance
77. lr_think_time
Pauses execution between commands in a script.
lr_think_time(10);
78. lr_user_data_point
79. lr_user_data_point_ex
80. lr_user_data_point_instance
81. lr_user_data_point_instance_ex
82. lr_vuser_status_message
83. lr_wasted_time
84. lr_whoami
85. lr_xml_get_values
86. lr_xml_set_values
87. lr_xml_extract
88. lr_xml_delete
89. lr_xml_replace
90. lr_xml_insert
91. lr_xml_find
92. lr_xml_transform
93. lr_unzip
94. lr_zip
Let me know if you want to add something to this blog. Please also share your feedback.
No comments:
Post a Comment