Saturday 15 August 2015

Functions in load Runner



Functions:-
1,
In the following example, lr_error_message sends a message to the LoadRunner output window or Application Management agent log file if the login fails. lr_abort is then invoked to abort the script.
2.
The following example uses abs to convert the integers 23 and -11 to their absolute values:
       int m = 23, n = -11;
       lr_output_message ("absolute value of %d = %d", m, abs(m));
       lr_output_message ("absolute value of %d = %d", n, abs(n));
3
In the following example, the web_add_cookie function adds a cookie with the name "client_id" to the list of cookies available to the script.
web_add_cookie ("client_id=China127B; path=/; expires=Wednesday, 09–Nov–2001 23:12:40 GMT; domain=www.cnn.com");
4
 The following example gets the time as a time_t structure and converts it to a tm structure, gmt, in Coordinated Universal Time.asctime then takes gmt and converts it to a string.
5
The following example converts the initial portion of the string, s, to a float.
double atof (const char *string); /* Explicit declaration */

vuser_init() {

     float x;
     char *s = "7.2339 by these hilts or I am a villain else";

     x = atof(s);     /* The %.2f formatting string limits the output to 2 decimal places */
     lr_output_message("%.2f", x);

     return 0;
}
Output:
vuser_init.c(11): 7.23
6
The following example converts the initial portion of the string, s, to an integer.
       int i;
       char * s = "7 dollars";
       i = atoi(s);
       lr_output_message ("Price $%d", i);
Output:
vuser_init.c(7): Price $7

No comments:

Post a Comment