Below are few frequently used LR functions
1) lr_ouput_message()
2) lr_message()
3) lr_error_message()
4) lr_log_message()
5) lr_save_datetime()
6) lr_save_string()
7) lr_save_int()
8) lr_eval_string
Example program to demonstrate
Action()
{
lr_output_message("Welcome to load runner")
}
Output: Action.(3):Welcome to load runner
Note:-If u want to see only message without logs then go to Run Time Settings and disable logs
To display the message (which is stored in a variable)
Action()
{
char *temp="Hyderabad";
lr_output_message("%s",temp);
return 0;
}
Output:Action.(5):Welcome to load runner
Note:- If u want to ignore the line numbers then use lr_message instead of lr_output_message
Action()
{
char *temp="Hyderabad";
lr_message("%s",temp);
return 0;
}
1) lr_ouput_message()
2) lr_message()
3) lr_error_message()
4) lr_log_message()
5) lr_save_datetime()
6) lr_save_string()
7) lr_save_int()
8) lr_eval_string
LR_OUTPUT_MESSAGE()
This function is used to display the message in an output window.Example program to demonstrate
Action()
{
lr_output_message("Welcome to load runner")
}
Output: Action.(3):Welcome to load runner
Note:-If u want to see only message without logs then go to Run Time Settings and disable logs
To display the message (which is stored in a variable)
Action()
{
char *temp="Hyderabad";
lr_output_message("%s",temp);
return 0;
}
Output:Action.(5):Welcome to load runner
Note:- If u want to ignore the line numbers then use lr_message instead of lr_output_message
Action()
{
char *temp="Hyderabad";
lr_message("%s",temp);
return 0;
}
Output:Welcome to load runner
LR_LOG_Message():-
This function is used to display a log message .It will writes the log message in to log file.
Action()
{
char *temp="Hyderabad";
lr_log_message("%s",temp);
return 0;
}
This function is used to display a log message .It will writes the log message in to log file.
Action()
{
char *temp="Hyderabad";
lr_log_message("%s",temp);
return 0;
}
Output:Welcome to load runner
Note: To enable logs go to Run Time Settings and enable logs and log messages will be saved into log file during the test execution in controller.
LR_SAVE_DATETIME():
It captures and saves the system's current date and time.
below are the few keywords which are used in lr_save_datetime
a----------------------------------->day with a part of name
A---------------------------------->Full name of the day.
b----------------------------------->name of the month(only a part of the month name)
B----------------------------------->Full name of the month
#----------------------------------->Will ignores 0 in the month
%d--------------------------------->To display the day in digits
%m--------------------------------->To display the month in digits
%M--------------------------------->To display the minutes
%y----------------------------------->displays year but contains only 2 digits
%Y---------------------------------->displays year but contains 4 digits
%c-----------------------------------> system current time along with time
date_now
A system keyword to captures the today's date
Action()
{
lr_save_datetime("%c",date_now,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Action()
{
lr_save_string("welcome to load runner","abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Action()
{
char *temp="welcome to load runner";
lr_save_string(temp,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Note:
lr_save_string canot save the int values in to string variable
Action()
{
lr_save_int(1213123,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Action()
{
int i=1213123;
lr_save_int(i,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Note:
lr_save_string canot save the int values in to string variable
Note: To enable logs go to Run Time Settings and enable logs and log messages will be saved into log file during the test execution in controller.
LR_SAVE_DATETIME():
It captures and saves the system's current date and time.
below are the few keywords which are used in lr_save_datetime
a----------------------------------->day with a part of name
A---------------------------------->Full name of the day.
b----------------------------------->name of the month(only a part of the month name)
B----------------------------------->Full name of the month
#----------------------------------->Will ignores 0 in the month
%d--------------------------------->To display the day in digits
%m--------------------------------->To display the month in digits
%M--------------------------------->To display the minutes
%y----------------------------------->displays year but contains only 2 digits
%Y---------------------------------->displays year but contains 4 digits
%c-----------------------------------> system current time along with time
date_now
A system keyword to captures the today's date
Action()
{
lr_save_datetime("%c",date_now,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
LR_SAVE_STRING():
This function is used to save the string value into another string variable
This function is used to save the string value into another string variable
Action()
{
lr_save_string("welcome to load runner","abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Action()
{
char *temp="welcome to load runner";
lr_save_string(temp,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Note:
lr_save_string canot save the int values in to string variable
LR_SAVE_INT():
This function is used to save the int value into another string variable
This function is used to save the int value into another string variable
Action()
{
lr_save_int(1213123,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Action()
{
int i=1213123;
lr_save_int(i,"abc");
lr_output_message(lr_eval_string("{abc}"));
return 0;
}
Note:
lr_save_string canot save the int values in to string variable
No comments:
Post a Comment