LR functions

LR functions you can use across the protocols.

1. lr_abort(); This function use for script abort purpose .

example:
 if (strcmp(lr_eval_string("{ramana}"), "0") == 0)
{
lr_output_message("Login Failed");
lr_abort();
}
else
 {
lr_output_message("Login PASSSSED");
 }

2. lr_exit(): Exits the iteraion or action.

Arguments:
LR_EXIT_USER
LR_EXIT_ACTION_AND_CONTINUE
LR_EXIT_MAIN_ITERATION_AND_CONTINUE
LR_EXIT_ITERATION_AND_CONTINUE
LR_EXIT_VUSER_AFTER_ITERATION.

Example:

if (strcmp(lr_eval_string("{ramana}"), "0") == 0)
{
lr_output_message("Login Failed");
lr_exit(LR_EXIT_MAIN_ITERATION_AND_CONTINUE, LR_FAIL); // here v
can change the above arguments.......
}
else
 {
lr_output_message("Login PASSSSED");
 }

3. lr_start_transaction()&lr_stop_transaction():  Allow you to measure the response time for a page/request.
lr_start_transaction("launch"); //here launch is txn name. this statement write on top of request
lr_stop_transaction("launch"); //this statement write after the request

4. lr_stop_transaction() &lr_resume_transaction()Transaction will be stopped and resumed based on requirement

5. lr_start_timer() &lr_end_timer():  This function will allow you to calculate wasted time. Nowadays you don’t require to calculate
wasted time which will be measured by LR itself.
 double time_elapsed, waste;
 merc_timer_handle_t timer;
 timer = lr_start_timer(); // this should write after the web function. or after start
transaction
 time_elapsed = lr_end_timer(timer);// this should after the web_reg_find function or
before ending transaction
 waste = time_elapsed * 1000; // Convert to millisecond.s
 lr_wasted_time(time_elapsed); /* Remove the time the checks took from the
transaction. */
 lr_output_message("%lf",time_elapsed);

6. lr_save_string(): It assigns a value to LR variable

Ex: lr_save_string("abc","xyz");

7. lr_save_int(): It assigns integer value in to LR variable.
this also used instead of itoa function.
lr_save_int(x, "xyz"); // here X is a integer

8. lr_eval_string():  It evaluate the value after embedding parameter or it reads the value.

9. lr_paramarr_random(): It generates the random value from an array.
lr_paramarr_random("source");

10. lr_paramarr_idx(): Returns the value of the parameter at a specified location

lr_paramarr_idx("source",10); // it reads 10 th value of source.

11. lr_save_datetime(): Assigns the current date and time to a parameter.

Ex:
lr_save_datetime("%m/%d/%Y %H:%M", DATE_NOW, "currDateTime"); // This statement
write in output message area(after the request)

12. lr_set_debug_message(): Changes the message level for a request

Syntax:
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |
LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_ON );
web_url()
---
----
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG |
LR_MSG_CLASS_FULL_TRACE, LR_SWITCH_OFF );
Note:Here we need to set standard mode in Runtime Settings.

13. lr_db_connect(): It connects to database with the help of connection statements

14. lr_db_disconnect(): It disconnects from the database

15. lr_db_executeSQLstatements(): Submits SQL statements to database

16. lr_continue_on_error(): On error, scripts use one of these options for continuation:

Syntax:
lr_continue_on_error(0); -------> no option
lr_continue_on_error(1); -------> continue
lr_continue_on_error(2); -------> skip to next Action
lr_continue_on_error(3); -------> skip to next iteration
lr_continue_on_error(4); -------> end user

17. lr_load_dll(): The 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. You can specify a full path for the DLL.
Syntax:
lr_load_dll("user32.dll");

18. lr_out_message(): It's sends a message to log file,output windows and summary report

19. lr_log_message(): Sends a message to logfile to the application management agent logfile (or) vuser log.

20. lr_message(): Sends a message to the log and o/p window.

21. lr_error_message(): Sends an error message with location details to the output windows, log files, and other test report summaries.

22. lr_get_vuser_ip(): Returns the ip address of the user
Syntax:
char* ip;
Ip= lr_get_vuser_ip();

23. lr_get_host_name(): Returns the name of the host
Syntax:
char* name;
Ip= lr_get_host_name();

24. lr_get_master_host_name(): Retrieve the controller machine name

25. lr_whoami(): Returns the information about vuser

26. lr_vuser_status_message(): Sends a message to vuser status area in controller

27. lr_save_searched_string(): It will captures substring from a main string

Syntax:
ex: for flight number 300;365;05/08/2016
char abc[100];
//this code write after the request
no option
strcpy(abc,lr_eval_string("{outboundFlight}"));
lr_save_searched_string(abc, strlen(abc),
1,";", //Searched for 2nd occurrence of “;”
0, //Indicates no skip after “;”
3, //Captures next 3 characters
"year"); // here year is final value (or )abc saved in year

No comments:

Post a Comment