Loadrunner Scripting 
- Recording level
     
 
  | 
HTML-Mode | 
URL-Mode | 
GUI-Mode | 
  | 
Script describing user actions in the form of web_url,
  web_link, web_image etc. Best for browser applications without JavaScript | 
Script describing user actions in the form of web_url. Best
  for applet and non-browser application | 
Record HTML actions ascontext sensitive GUI functions such as web_text_link.This is the ideal
  recording level for Oracle Web Applications 11i and PeopleSoft Enterprise.
  Best for browser applications with JavaScript
 | 
- web_image_check(Within
     HTML-based scripts (not URL-based scripts)
Syntax
: web_image_check("","", LAST)
Ex:
web_image_check("imgae1","src=filepath/image001.jpg",LAST);
- web_reg_find
 It search for a text string for the very next Action function in the
     script. It scans the buffers as they arrive rather than after a page is
     received.
 Syntax : web_reg_find("Text=", LAST);
     
web_reg_find returns 1 (constant LR_FAIL) if it fail. 
     
web_reg_find returns 0 (constant LR_PASS) if it successful
    
"NOTFOUND=warning","SaveCount=pCountA","Search=All"
     
Ex: web_reg_find("Text=Google", LAST);
- Manual
     Correlation  
To save
and display text , use web_reg_save_param command to extract text after
searching it between tokens LB and RB (Left and Right Beacons) non-NULL
terminated dynamic data from an HTML page to a parameter.
      
web_reg_save_param("text_extracted","LB=xxx","RB=xxx",
LAST);
       
//change LB to LB/ic if you want to ignore case sensitveness
web_reg_save_param("Buffer","LB/ic=","RB=",
LAST );
 int web_reg_save_param(const char *paramName, , LAST);
  
NotFound is  a handling method which invokes when
a boundary is not found and it generates an empty string. “ERROR,” is the
default value. “EMPTY,” no error message and script execution continues. This
parameter is optional.
LB The left boundary of the data. Boundary parameters are case
sensitive; to ignore, add “/IC” after the boundary. Specify “/BIN” after
boundary to specify binary data. This is must.
RB The right boundary of the data. Boundary parameters are case
sensitive; to ignore, add “/IC” after the boundary. Specify “/BIN” after
boundary to specify binary data. This is must.
ORD This parameter indicates the number of matches or instance
(occurrence). It saves the parameter values in an array, if you specify “All”.
The default value is 1. This parameter is optional.
These Attributes are rarely used :
RelFrameID The hierarchy level of HTML page relative to
requested URL.
Search It specifies scope of search. The possible values are Headers,
Body, or ALL (searches in both Body and headers). The default value is ALL.
SaveOffset The offset of a sub-string of found value, to
save to the parameter. The default is 0. Offset value must be non-negative.
Savelen It specifies length of the string of found
value, to save to the parameter. The default is -1, indicating full length of
the string.
Convert  HTML_TO_URL: convert HTML-encoded data
to a URL-encoded data format and HTML_TO_TEXT: convert HTML-encoded data to
plain text format
Ex:
web_reg_save_param("Jsession","LB= Set-Cookie:”,
"RB=";", "Ord=All", "NotFound=EMPTY", LAST);
5.      lr_log_message
    
       Sends a message to a log file.
           
Syntax: int lr_log_message (const char * format, exp1,...expn.);
           
Ex: lr_log_message (“ Jsession = %s”, jsession);
   
       lr_output_message 
    
     Sends a message to the Output window or the
Business Process Monitor log files.
          
Syntax: int lr_output_message (const char * format, exp1,...expn.);
          
Ex : lr_output_message(“ Jsession = %s”, jsession);
   
      lr_vuser_status_message 
 Sends
a string to the Status area of the Controller or Tuning Module Console's
   Vuser window. It also sends this string to the Vuser log. Not
applicable for Application Management.
          
Syntax: int lr_vuser_status_message (const char * format.);
          
Ex : lr_vuser_status_message (“ Jsession = %s”, jsession);
- lr_abort
 
       The lr_abort function aborts the
execution of a script . It stops the execution of the 
  
      Actions section, executes the vuser_end
section, and ends the execution. This 
function
is useful when you need to manually abort a run as a result of a specific error
condition. When you end a run using this function, the status is
"Stopped."
     
   Syntax: void lr_abort( );
    
    Ex:  lr_abort( );
- lr_save_string 
     
   
      The lr_save_string function assigns the
specified null-terminated string
   
      to a parameter. This function is useful in
correlating queries.
   
      Syntax: int lr_save_string (const char
*param_value, const char *param_name);
 
        Ex:  lr_save_string(
buffer, “jsession”);
- lr_eval_string
The
lr_eval_string function returns the input string after evaluating any embedded
    parameters. If string argument contains only a
parameter, the function returns the current value of the parameter. 
     
Syntax: char * lr_eval_string (const char * instring );
     
Ex: lr_eval_string("{jsession}")
- lr_whoami 
     
      The lr_whoami function gets information
about the Vuser.
    
       Syntax: void lr_whoami (int
*vuser_id, char **sgroup, int *scid); 
   
        Ex: lr_whoami(&vuser,
&vuser_group, NULL);
- lr_think_time 
   
        lr_think_time allows you to
pause test execution during a run. This is especially 
useful
in simulating think time, the time a real user pauses to think between actions.
     
Syntax: void lr_think_time (double time); time is in sec
     
Ex: lr_think_time (10);
- lr_load_dll 
     
   The lr_load_dll function loads a DLL (Windows) or shared
object (UNIX) 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. 
- web_add_header
    
Adds a user-defined header to the next HTTP request
    
Syntax: int web_add_header (const char *Header, const char *Content );  
    
Ex: web_add_header("Cookie",cookieString);
- web_cache_cleanup();
- lr_continue_on_error(1);
     
tells LR to continue execution even on error.
     
lr_continue_on_error(0);
   
        tells LR to terminate execution
on error
 
  | 
C Constants  | 
Object Oriented Value
  (no constants)  | 
  | 
LR_ON_ERROR_NO_OPTIONS
 | 
0  | 
  | 
LR_ON_ERROR_CONTINUE
 | 
1  | 
  | 
LR_ON_ERROR_SKIP_TO_NEXT_ACTION
 | 
2  | 
  | 
LR_ON_ERROR_SKIP_TO_NEXT_
 ITERATION
 | 
3  | 
  | 
LR_ON_ERROR_END_VUSER
 | 
4  | 
  | 
LR_ON_ERROR_CALL_ 
USER_DEFINED_HANDLER | 
5 | 
       
  lr_exit(LR_EXIT_ITERATION_AND_CONTINUE,LR_FAIL);
 
  | 
C Constants  | 
Object Oriented Value
  (no constants)  | 
  | 
LR_EXIT_VUSER | 
0  | 
  | 
LR_EXIT_ACTION_AND_CONTINUE | 
1  | 
  | 
LR_EXIT_ITERATION_AND_CONTINUE | 
2  | 
  | 
LR_EXIT_VUSER_AFTER_ITERATION | 
3  | 
  | 
LR_EXIT_VUSER_AFTER_ACTION | 
4  | 
          
Macro’s for result directory:
 
  | 
Macro | 
Value (no constants)  | 
  | 
LR_PASS | 
0  | 
  | 
LR_FAIL | 
1  | 
  | 
LR_AUTO | 
2 | 
  | 
LR_STOP | 
3 | 
- Transaction
     statements to get transaction timing
   
      lr_start_transaction("Start"); 
lr_start_sub_transaction("substart","start");
lr_end_sub_transaction("substart",LR_AUTO);
  
lr_end_transaction("Start",LR_AUTO);
- Put
     lr_set_debug_message before the request for which you want log setting
     to  
     
change
          
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG
| LR_MSG_CLASS_RESULT_DATA | LR_MSG_CLASS_PARAMETERS |
LR_MSG_CLASS_FULL_TRACE,LR_SWITCH_ON);
/* 
Actions
*/
lr_set_debug_message(LR_MSG_CLASS_EXTENDED_LOG
| LR_MSG_CLASS_RESULT_DATA | LR_MSG_CLASS_PARAMETERS |
LR_MSG_CLASS_FULL_TRACE,LR_SWITCH_OFF);
 
  | 
Type | 
Description | 
  | 
Generic Logging Settings | 
  | 
LR_MSG_CLASS_DISABLE_LOG | 
Flag for un-checking Enable Logging in the Runtime settings. | 
  | 
LR_MSG_CLASS_BRIEF_LOG | 
Flag for Standard Log. | 
  | 
LR_MSG_CLASS_EXTENDED_LOG | 
Flag for Extended Log | 
  | 
Extra Settings for Extended Log | 
  | 
LR_MSG_CLASS_RESULT_DATA | 
Flag for Data returned by server. | 
  | 
LR_MSG_CLASS_PARAMETERS | 
Flag for Parameter substitution. | 
  | 
LR_MSG_CLASS_FULL_TRACE | 
Flag for Advanced Trace. | 
  | 
Log Options | 
  | 
LR_MSG_CLASS_JIT_LOG_ON_ERROR | 
Only on error. Corresponds to “Send messages only when an
  error occurs”. | 
- In order get the
     info on the downloaded file use following function after the web_url, etc
     request send to get PDF or Excel file, we can then use this info to
     compare the actual size on the server.
Size =
web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE)
Time=
web_get_int_property(HTTP_INFO_DOWNLOAD_TIME)
- C functions:
            
strcat Concatenates two strings.
            
strcmp Compares two strings to determine the alphabetic order.
                        
A zero value indicates that both strings are equal.
            
strcpy Copies one string to another.
            
strlen Returns the length of a string.
            
long fp, fp1;       
            
char tempy[100];    
            
int sprintf ( char * str, const char * format, ... );
            
e.g. sprintf(currValue,"{User_Id_%d}",i);
        
    char * strtok ( char * str, const char * delimiters );
        
    char *strtok(char * ,char *);
   
         mToken =(char *)strtok
(lr_eval_string(currValue),mSeperator);
      
      fp =
fopen(lr_eval_string("C:\\UserId1.txt"),"r");
           
 fscanf(fp,"%s", &tempy);
           
 lr_save_string(tempy,"UserId2");
           
 fclose(fp);
       
      fp =
fopen(lr_eval_string("C:\\UserId1.txt"),"w+");
           
  fprintf(fp,"%s",lr_eval_string("{LoginUserId}"));
           
  fclose(fp);