Monday, June 3, 2013

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
7
Function Name
Description
abs
Gets the absolute value of an integer.
asctime
Converts time from a structure to a string.
atof
Converts a string to a floating point value.
atoi
Converts a string to an integer value.
atol
Converts a string to a long integer value.
calloc
Allocates an array and initializes all elements to zero.
chdir
Changes the current directory to the given path.
chdrive
Switches to another drive.
cos
Computes the cosine of an angle in radians.
ctime
Converts the calendar time to local time.
fclose
Closes a file.
feof
Checks if the end of file has occurred on a stream.
ferror
Checks if any error has occurred during file I/0.
fgetc
Gets a character from a stream.
fgets
Reads a string from a file.
floor
Gets the largest integral value that is less than x.
fopen
Opens a file for buffered I/0.
fprintf
Writes formatted output to a file.
fputc
Writes a character to a stream.
fread
Reads unformatted data from a stream into a buffer.
free
Frees a block of memory.
fscanf
Reads formatted input from a stream.
fseek
Sets the current position in a file to a new location.
ftime
Prints time information to a structure.
fwrite
Write unformatted data from a buffer to a stream.
getcwd
Returns the name of the current working directory.
getdrive
Returns the name of the current drive.
getenv
Gets the definition of an environment variable.
gmtime
Converts the calendar time into Coordinated Universal Time (UTC).
isalpha
Checks if a string is a letter.
isdigit
Checks if a string is a decimal digit.
Converts an integer to a string. Windows only.
localtime
Converts the calendar time into local time.
malloc
Allocates a block of memory.
memchr
Searches for a character in a buffer.
memcmp
Compares two buffers.
memcpy
Copies n characters from one buffer into another.
memmove
Moves a number of bytes from one buffer to another.
memset
Sets n bytes of a buffer to a given character.
mkdir
Creates a directory using the given path name.
putenv
Inserts a new definition into an environment table.
rand
Gets a random integer between 0 and RAND_MAX.
realloc
Reallocates (adjusts the size of) a block of memory.
remove
Deletes the specified file.
rewind
Rewinds a file.
rmdir
Deletes the specified directory.
sin
Computes the sine of an angle in radians.
sprintf
Writes formatted output to a string.
sqrt
Computes the square root of x.
sscanf
Reads formatted input from a string.
strcat
Concatenates two strings.
strchr
Returns the pointer to the first occurrence of a character in a string.
strcmp
Compares two strings to determine the alphabetic order.
strcpy
Copies one string to another.
strdup
Duplicates a string.
stricmp
Performs a case-insensitive comparison of two strings.
strlen
Returns the length of a string.
strlwr
Converts a string to lower case.
strncat
Concatenates n characters from one string to another.
strncmp
Compares the first n characters of two strings.
strncpy
Copies the first n characters of one string to another.
strnicmp
Performs a case-insensitive comparison of n strings.
strrchr
Finds the last occurrence of a character in a string.
strset
Fills a string with a specific character.
strspn
Returns the length of the leading characters in a string that are contained in a specified string.
strstr
Returns the first occurrence of one string in another.
strtok
Returns a token from a string delimited by specified characters.
strtol
Converts a string to a long integer using a given radix.
strupr
Converts a string to upper case.
system
Executes an operating system command.
time
Returns the current calendar time.
tolower
Converts a string to lowercase.
toupper
Converts a string to uppercase.
8.
In the following example, lr_error_message sends a message to the LoadRunner output window or Application Management agent log file if login fails:
int status = web_url("Login",
          "URL=https://secure.computing.com//login.asp?user={username}&session={ssid}",
          "RecContentType=text/html", LAST);

if (status == LR_FAIL) {

     lr_error_message("Error: %s", "Unable to login to secure computing");
     return -1;
}
9
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.
10.
In the following example, lr.eval_int returns the value of parameter ID_num.
// Create the parameter
lr.save_int(12,"ID_num");
// Output the parameter value
lr.message(" Track Stock : " + lr.eval_int("<ID_num>") );
Example 2 - Parameterization
In the following example, lr.eval_int substitutes the parameter string STID with appropriate values for each iteration.
lr.message( "Stock Trader ID Number is " + lr.eval_int("<STID>") );
11.
C Constants
Object Oriented Constants
Behavior
LR_EXIT_VUSER
lr.EXIT_VUSER
Exit without any condition, and go directly to end action
LR_EXIT_ACTION_
AND_CONTINUE
lr.EXIT_ACTION_
AND_CONTINUE
Stop current action, and go to the next action.
LR_EXIT_MAIN_
ITERATION_
AND_CONTINUE
lr.EXIT_MAIN_
ITERATION_
AND_CONTINUE
Stop current global script run iteration, and go to the next iteration.
LR_EXIT_ITERATION_
AND_CONTINUE
lr.EXIT_ITERATION_
AND_CONTINUE
Stop current iteration, and go to the next iteration.
If called from within a block iteration, only the block iteration will be exited, and not the global iteration.
LR_EXIT_VUSER_
AFTER_ITERATION
lr.EXIT_VUSER_
AFTER_ITERATION
Run until the end of the current iteration and then exit.
LR_EXIT_VUSER_
AFTER_ACTION
lr.EXIT_VUSER_
AFTER_ACTION
Run until the end of the current action and then exit.
12.
13

Example: feof

The following example, for Windows platforms, opens a file and reads it into a buffer until feof returns true, indicating the end of the file.
To run the example, copy the file readme.txt from the installation's dat directory to the c drive, or copy another file and change the value of filename.
14.
The following example, for Windows platforms, opens a file and reads it into a buffer. ferror checks for errors on the read file stream.
15
The following example, for Windows platforms, opens a file using fopen, reads it into a buffer, and then closes it.
To run the example, copy the file readme.txt from the installation's dat directory to the c drive, or copy another file and change the value of filename.
       int count, total = 0;
       char buffer[1000];
       long file_stream;
       char * filename = "c:\\readme.txt";
       // Open the file with read access
       if ((file_stream = fopen(filename, "r")) == NULL) {
              lr_error_message ("Cannot open %s", filename);
              return -1;
       }
       // Read until end of file
       while (!feof(file_stream)) {
              // Read 1000 bytes while maintaining a running count
              count = fread(buffer, sizeof(char), 1000, file_stream);
              lr_output_message ("%3d read", count);
              // Check for file I/O errors
              if (ferror(file_stream)) {
                     lr_output_message ("Error reading file %s", filename);
              break;
              }
              total += count; // Add up actual bytes read
       }
       // Display final total
       lr_output_message ("Total number of bytes read = %d", total );
       // Close the file stream
       if (fclose(file_stream))
              lr_error_message ("Error closing file %s", filename);
Output:
Action.c(19): 1000 bytes read
Action.c(19): 1000 bytes read
...
Action.c(19): 1000 bytes read
Action.c(20): 977 read
Action.c(34): Total number of bytes read = 69977
16.
The following example opens a log file and writes the id number and group name of the Virtual User to it using fprintf.
       #ifdef unix
              char * filename = "/tmp/logfile.txt";
       #else
              char * filename = "c:\\logfile.txt";
       #endif
       long file;
       int id;
       char * groupname;
       // Create a new file
       if ((file = fopen(filename, "w+" )) == NULL) {
              lr_output_message("Unable to create %s", filename);
              return -1;
       }
       // Write the Vuser id and group to the log file
       lr_whoami(&id, &groupname, NULL);
       fprintf(file, "log file of virtual user id: %d group: %s\n", id, groupname);
       fclose(file);
Written to log file:
log file of virtual user id: -1 group: None
17.
The following example uses free to de-allocate a buffer of length 1024.
18.
The following example, for Windows platforms, opens a file and reads it into a buffer. If file errors occur during the process, goto is used to escape the enclosing loop to code which prints an error message and exits the function.
int count, total = 0;
       char buffer[1000];
       long file_stream;
       char * filename = "c:\\xyzpqi.txt";
       // Open the file with read access
       if ((file_stream = fopen(filename, "r")) == NULL)
              goto file_error;
       // Read until end of file
19.
In the following example, lr_log_message sends a message to the log file if the connection to the server fails.
char* abort="aborting...";
...
if (init() < 0) {
       lr_log_message ("login failed: %s", abort);}
       return(0);
}
20.
In the following example, lr_message sends a message if the connection to the server fails.
char* abort="aborting...";
...
if (init() < 0) {
       lr_message ("login failed: %s", abort);}
return(0);
}
21,
In the following example, ID is a parameter defined in the Parameter list. The lr_next_row function advances to the next row in the ID.dat file.
lr_message( "Connect to Stock Trader ID Number %s",
       lr_eval_string("{ID}") );
lr_next_row("ID.dat");
lr_message( "Connect to Stock Trader ID Number %s",
       lr_eval_string("{ID}") );
The output window shows:
Connect to Stock Trader ID Number 2347
Connect to Stock Trader ID Number 2348
22.
In this example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_output_message function sends a message to the Load Runner Controller or the Application Mangement Admin Center indicating the current iteration number.
lr_output_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );
23.
In the following example, the lr_rendezvous function sets the Meeting rendezvous point. When all users that belong to the Meeting rendezvous arrive at the rendezvous point, they perform do_transaction simultaneously.
lr_rendezvous("Meeting");
       do_transaction(); /* application dependent transaction */
24. In the following example, lr.save_data assigns a series of values to the ID parameter. This parameter is then used in an output message.
// Example array of arbitrary bytes.
byte [] b_arr = new byte[]{(byte)0x12,(byte)0x2,(byte)0x1,(byte)0x3};
// Save the array into parameter ID
lr.save_data(b_arr,"ID");
// Save the contents of the array parameter to another array
byte [] output_arr = lr.eval_data("<ID>");
lr.output_message("This is the value of the first output byte: "
       + Byte.toString(output_arr[0]));
25
In the following example, lr_load_dll is used so that a standard Windows message box can be displayed during script replay:
lr_load_dll("user32.dll");
MessageBoxA(NULL, "This is the message body", "message_caption", 0);
26.
In the following example, lr_log_message sends a message to the log file if the connection to the server fails.
char* abort="aborting...";
...
if (init() < 0) {
       lr_log_message ("login failed: %s", abort);}
       return(0);
}
In the next example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_log_message function sends a message to the LoadRunner Controller or Application Management Admin Center indicating the current iteration number.
lr_log_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );
27.
In the following example, lr_message sends a message if the connection to the server fails.
char* abort="aborting...";
...
if (init() < 0) {
       lr_message ("login failed: %s", abort);}
return(0);
}
28.
In this example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_output_message function sends a message to the Load Runner Controller or the Application Mangement Admin Center indicating the current iteration number.
lr_output_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );
29.
In the following example, lr_save_datetime is used to retrieve tomorrow's date.
lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");
lr_output_message(lr_eval_string("{next}"));
30.
In the following example, lr_save_int assigns the string representation of the value of variable num times 2 to parameter param1.
int num;
num = 5;
lr_save_int(num * 2, "param1");
The value of param1 is now "10".
31.
In this example, the lr_set_debug_message function enables the full trace option just before a call to lrd_fetch, which the user needs to debug because it has been giving unexpected results.
The second invocation of lr_set_debug_message resets the debug level to what it was formerly, by turning off (LR_SWITCH_OFF) the Extended message level.
32.
In the following segment, lr_start_timer and lr_end_timer are used to calculate the time spent on checks. This is then subtracted from the time spent on transaction "sampleTrans" with lr_wasted_time.
double time_elapsed, duration, waste;
merc_timer_handle_t timer;
       lr_start_transaction("sampleTrans");
       web_url("index.htm",
              "URL=http://localhost/index.htm",
              "TargetFrame=",
              "Resource=0",
              "RecContentType=text/html",
              "Referer=",
              "Snapshot=t1.inf",
              "Mode=HTML",
              LAST);
       timer = lr_start_timer();
/* Do some checks the duration of which
is not to be included in the transaction. */
       web_image_check("ImgCheck1",
              "src=index_files/image002.jpg",
              LAST);
       web_image_check("ImgCheck2",
              "src=index_files/planets.gif",
              LAST);
// How long did the tests take in seconds.
       time_elapsed = lr_end_timer(timer);
// Convert to millisecond.s
       waste = time_elapsed * 1000;
/* Remove the time the checks took from
       the transaction. */
       lr_wasted_time(waste);
        lr_end_transaction("sampleTrans", LR_AUTO);


In the following segment, lr_think_time instructs the script to pause for 10 seconds after accessing a link and submitting a form.
In the following example, a user data point is defined that checks the CPU every second and records the result.
for (i=0;i<100;i++) {
       measure_cpu ( );
       cpu_val=cpu_check();
       lr_user_data_point("cpu", cpu_val);
       sleep(1);
}
30
The following segment demonstrates the use of timers to collect wasted time, and the use of lr_wasted_time to remove that wasted time from the transactions. The output log segments below show that the effects are not reported in the Vuser log, but are reported in the Analysis session.
31.
In the following example, lr_whoami retrieves information about a Vuser and places it into a message string. The message string contains Vuser login information that is used to connect with a server.
Note that memory for vuser_group is allocated automatically. Do not alter the string.
           
        vuser_group, id, scid);
32.RTE functions
TE_connect
Connects the terminal emulator to the specified host.
TE_find_text
Searches for text in a designated area of the screen.
TE_get_line_attribute
Returns information about text formatting.
TE_get_text_line
Reads text from a designated line on the screen.
TE_get_cursor_pos
Returns the current location of the cursor.
TE_set_cursor_pos
Sets the position of the cursor on the terminal screen.
TE_getvar
Returns the value of an RTE system variable.
TE_setvar
Sets the value of an RTE system variable.
TE_perror
Prints an error code to the LoadRunner output window or Business Process Monitor agent log.
TE_sperror
Translates an error code into a string.
TE_send_text
Sends a null-terminated string to a VT terminal emulator.
TE_type
Sends a formatted string to the client application.
TE_typing_style
Determines the way text is typed into the terminal emulator.
TE_unlock_keyboard
Unlocks the keyboard of a mainframe terminal
TE_wait_cursor
Waits for the cursor to appear at a specified location in the terminal window.
TE_wait_silent
Waits for the client application to be silent for a specified number of seconds.
TE_wait_sync
Waits for the system to return from X-SYSTEM or Input Inhibited mode.
TE_wait_sync_transaction
Records the time that the system remained in the most recent X SYSTEM mode.
TE_wait_text
Waits for a string to appear in a designated location.
In these examples, web_save_param_length creates three new parameters, Param7_Length, Param10_Length,and Param16_Length, and stores the length of each respective source parameter as a hexidecimal number.
       // Create a parameter 7 characters long
       lr_save_string("ABCDEFG", "Param7");
       web_save_param_length("Param7", "Base=Hexadecimal", LAST);
       // Output: Action.c(9): Notify: Saving Parameter "Param7_Length = 7"
       // Create a parameter 10 characters long
       lr_save_string("ABCDEFGHIJ", "Param10");
       web_save_param_length("Param10", "Base=Hexadecimal", LAST);
       //Output is in hexadecimal:
       //Action.c(14): Notify: Saving Parameter "Param10_Length = A"
       // Create a parameter 16 characters long
       lr_save_string("ABCDEFGHIJKLMNOP", "Param16");
       web_save_param_length("Param16", "Base=Hexadecimal", LAST);
       //Output is in hexadecimal:
       //Action.c(18): Notify: Saving Parameter "Param16_Length = 10"
The following examples are presented for web_reg_save_param.
  • Example 1: Saving simple text strings
    • Case of saving a single string
    • Case requiring handling arrays
  • Example 2: Saving a text by using binary boundaries
  • Example 3: Saving a text specified with an offset and length
  • Example 4: Boundaries containing special characters
Example 1: Saving simple text strings

In this example, web_reg_save_param is used to save a value from the response to a web_submit_form call. The value saved is used in a subsequent web_submit_form call.
In the Mercury Tours sample program, the server response to the web_submit_form call below contains the following radio button options:
<tr bgcolor=#66cccc><th>Flight<th>Departure time<th>Cost
<tr bgcolor=#66CCff><td align=center><input type = radio name=outboundFlight value=230;378;11/20/2003 checked >Blue Sky Air 230<td align=center>8am<td align=center>$ 378
<tr bgcolor=#eeeeee><td align=center><input type = radio name=outboundFlight value=231;337;11/20/2003>Blue Sky Air 231<td align=center>1pm<td align=center>$ 337
and so on.
To submit a reservation, the outboundFlight value is required. web_reg_save_param is used to save the outboundFlight value.
  • Case of saving a single string
  • Case requiring handling arrays
Case of saving a single string
To reserve the default flight, save the "checked" value, and pass it to web_submit_form. The html segment for the default value is:
name=outboundFlight value=230;378;11/20/2003 checked >
/*This web_reg_save_param call applies to the following action function: web_submit_form. */
       web_reg_save_param("outFlightVal",
       "LB=outboundFlight value=", "RB= checked >", LAST);
       web_submit_form("reservations.pl",
              "Snapshot=t4.inf",
              ITEMDATA,
              "Name=depart", "Value=London", ENDITEM,
              "Name=departDate", "Value=11/20/2003", ENDITEM,
              "Name=arrive", "Value=New York", ENDITEM,
              "Name=returnDate", "Value=11/21/2003", ENDITEM,
              "Name=numPassengers", "Value=1", ENDITEM,
              "Name=roundtrip", "Value=<OFF>", ENDITEM,
              "Name=seatPref", "Value=None", ENDITEM,
              "Name=seatType", "Value=Coach", ENDITEM,
              "Name=findFlights.x", "Value=83", ENDITEM,
              "Name=findFlights.y", "Value=16", ENDITEM,
              LAST);
/*
The result of the web_reg_save_param having been called before the web_submit_form is:
Action.c(15): Notify: Saving Parameter "outFlightVal = 230;378;11/20/2003"
*/
// Now use the saved outFlightVal
       web_submit_form("reservations.pl_2",
              "Snapshot=t5.inf",
              ITEMDATA,
              "Name=outboundFlight", "Value={outFlightVal}", ENDITEM,
              "Name=reserveFlights.x", "Value=92", ENDITEM,
              "Name=reserveFlights.y", "Value=10", ENDITEM,
              LAST);
/*
Action.c(34): Notify: Parameter Substitution: parameter "outFlightVal" = "230;378;11/20/2003" */

 
Case requiring handling arrays
If you want to test the last option returned by the web_submit_form call, save all the matches and then handle the array.
This example shows the use of web_reg_save_param with "ORD=ALL" to get an array of parameters. The last item in the array is then used to correlate a web_submit_form call.
char outFlightParam[50]; // The name of the parameter for correlation
char outFlightParamVal[50]; // The formatted value of outFlightParam
/*
This web_reg_save_param call applies to the following action function, web_submit_form. Because of the "ORD=ALL" argument, it saves all the values that have the given left and right boundaries to an array of parameters.
The SaveLen argument is used to restrict the length to 18 characters because the default value is "230;378;11/20/2003 checked >". We restrict the length so as not to capture the " checked ".
*/
       web_reg_save_param("outFlightVal",
              "LB=outboundFlight value=", "RB=>",
              "ORD=ALL",
              "SaveLen=18",
              LAST);
       web_submit_form("reservations.pl",
              "Snapshot=t4.inf",
              ITEMDATA,
              "Name=depart", "Value=London", ENDITEM,
              "Name=departDate", "Value=11/20/2003", ENDITEM,
              "Name=arrive", "Value=New York", ENDITEM,
              "Name=returnDate", "Value=11/21/2003", ENDITEM,
              "Name=numPassengers", "Value=1", ENDITEM,
              "Name=roundtrip", "Value=<OFF>", ENDITEM,
              "Name=seatPref", "Value=None", ENDITEM,
              "Name=seatType", "Value=Coach", ENDITEM,
              "Name=findFlights.x", "Value=83", ENDITEM,
              "Name=findFlights.y", "Value=16", ENDITEM,
              LAST);
/*
The result of the web_reg_save_param having been called before the web_submit_form is:
Notify: Saving Parameter "outFlightVal_1 = 230;378;11/20/2003"
Notify: Saving Parameter "outFlightVal_2 = 231;337;11/20/2003"
Notify: Saving Parameter "outFlightVal_3 = 232;357;11/20/2003"
Notify: Saving Parameter "outFlightVal_4 = 233;309;11/20/2003"
Notify: Saving Parameter "outFlightVal_count = 4"
The next problem is to get the highest array element, identified with the parameter outFlightVal_count. This parameter is automatically created by the script recorder. You do not have to enter anything in the script.
*/
/* Get the name of the parameter, in this case "outFlightVal_4".
Put it in brackets so it can be an input to an lr_eval_string call.
Note that the brackets in the second argument to sprintf are not indicating a script parameter to sprintf. They are string literals that will be part of outFlightParam after the call.
In the second call to sprintf, those brackets indicate a parameter to lr_eval_string.
*/
       sprintf(outFlightParam, "{outFlightVal_%s}",
              lr_eval_string("{outFlightVal_count}"));
/* outFlightParam is now "{outFlightVal_4}" */
       /* Now get the "Value" argument for web_submit_form, in the
              format "Value=xxxx")
       */
       sprintf(outFlightParamVal, "Value=%s",
              lr_eval_string(outFlightParam));
       lr_message("The value argument is : %s", outFlightParamVal);
       // The value argument is : Value=233;309;11/20/2003
       /* Now the string outFlightParamVal can be passed
              to web_submit_form */
       web_submit_form("reservations.pl_2",
              "Snapshot=t5.inf",
              ITEMDATA,
              "Name=outboundFlight",outFlightParamVal, ENDITEM,
              "Name=reserveFlights.x", "Value=92", ENDITEM,
              "Name=reserveFlights.y", "Value=10", ENDITEM,
              LAST);
 

 
Example 2: Saving a text by using binary boundaries

The following example uses BIN type boundaries. The left boundary is composed of 3F and DD. The right boundary is composed of CC and b.
web_reg_save_param("p", "LB/BIN=\\x3F\\xDD", "RB/BIN=\\xCCb", LAST);
 
Example 3: Saving a text specified with an offset and length

The following example specifies an offset and length. The boundaries for the HTML string "Astra on TESTSERVER", are "Astra " (note the space which follows the word) and "TestServer". This should return "on" but since the offset is 1 (i.e. start at the second character) and the length of data to save is 1, then the string saved to TestParam is "n".
web_reg_save_param("Param1", "LB=Astra ", "RB= TESTSERVER",
       "SaveOffset=1", "SaveLen=1", LAST);
 
Example 4: Boundaries containing special characters

The following example shows the use of escaping in the C language when the boundaries contain special characters.
The following HTML segment contains new line characters (paragraph markers) after each "<strong>" and quote marks around each class name. We want to save "Georgiana Darcy" to parameter "UserName". The segment containing the new line and quotes has to be included in the left boundary because "Name:", which precedes the segment, is required for the occurrence to be unique. The ORD attribute cannot be used in this case because the length of the list preceding the relevant element varies.
<span class="surveyQuestionReview"><strong> UserID:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Revere18041775</span> <br>
<span class="surveyQuestionReview"><strong> Name:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Georgiana Darcy</span> <br>
<span class="surveyQuestionReview"><strong> Company:</strong></span><strong>
    </strong> <span class="surveyAnswerReview">Pride and Prejudice</span> <br>
The function is:
web_reg_save_param("UserName",
"LB=Name:</strong></span><strong> \n    </strong> <span class=\"surveyAnswerReview\">",
              "RB=</span> <br>",
              LAST);
Note the \n for the new line character, and that the quote characters need to be escaped: \".
In the following example, web_reg_find searches for the text string "Welcome". If the string is not found, it fails and the script execution stops.
       // Run the Web Tours sample
       web_url("MercuryWebTours",
              "URL=http://localhost/MercuryWebTours/",
              "Resource=0",
              "RecContentType=text/html",
              "Referer=",
              "Snapshot=t1.inf",
              "Mode=HTML",
              LAST);
// Set up check for successful login by looking for "Welcome"
       web_reg_find("Text=Welcome",
              LAST);
// Now log in
       web_submit_form("login.pl",
              "Snapshot=t2.inf",
              ITEMDATA,
              "Name=username", "Value=jojo", ENDITEM,
              "Name=password", "Value=bean", ENDITEM,
              "Name=login.x", "Value=35", ENDITEM,
              "Name=login.y", "Value=14", ENDITEM,
              LAST);
-------
In the following example, the web_find function searches for the name "John" in the employees.html page.
web_url("index.html",
        "URL=http://server1/people/employees.html",
        "TargetFrame=",
        LAST);
web_find("Employee Check",
        "expect=notfound",
        "matchcase=yes",
        "onfailure=abort",
        "report=failure",
        "repeat=no",
        "what=John",
        LAST);
Example 2
In the following example, the web_find function searches for the text "Home" which is between "Go to" and "Page".
web_url("index.html",
        "URL=http://server1/",
        "TargetFrame=",
       LAST);
web_find("Text Check",
        "RightOf=Go to",
        "LeftOf=page",
        "What=Home",
       LAST);

web_submit_data

Return Values
Parameterization
Performs an "unconditional" or "contextless" form submission.







2 comments:

Unknown said...

usable information, my side one small suggestion, if it possible create one full video and send the link.

Anonymous said...

Excellent info. Many thanks for sharing