web_reg_save_param is used for LoadRunner script correlation. That's why every load tester should study this function thoroughly, if you wish your scripts work correctly.
Imagine that the server returns the following part of HTML page:
Note: I will refer to this example later.
- What boundaries should be used in web_reg_save_param LoadRunner function to capture value of "ID1" (abcde)?
The correct left boundary for web_reg_save_param function should be:
- ID1" value="
Do you know why it is? I will explain in details.
To find out the boundaries, we have to see texts located on the left and on the right.
What is the text located on the left? There are several variants:
- " (inverted comma)
Actually, inverted comma cannot be used as left boundary, because it is located in several places in server's responce.
So, we have to extend the left boundary:
- =" (equal sign and inverted comma)
These two characters also unusable, because it is located in several places too. For example, type="text" or value="abcde". So, we have to extend the left boundary again.
So, I recommend to include unique part - ID1:
- ID1" value="
These string occurs one time in server's response. So, it can identify uniquely the value of "ID1" (abcde).
We have found left and right boundaries, so the final web_reg_save_param function is:
Hint: Since left and right boundaries contains inverted commas, we have to insert backslash before.
Backslash followed by special characters are named Escape Sequences.
Let's execute our code.
For that, enable extended logging from Run-time Settings:
The result of LoadRunner script execution is the following:
As you can see, we specified correct boundaries for web_reg_save_param LoadRunner function. Value of ID1 has been captured correctly.
Hint: Use lr_eval_string function to get captured value (value of LoadRunner parameter).
- What boundaries should be used in web_reg_save_param LoadRunner function to user name (John Smith)?
Using of web_reg_save_param LoadRunner function looks similar to previous example with a small difference - we have to extract user name from several lines:
How to process this case? Piece of cake :)
Left boundary for user name is "User name:" text followed by a new line. In terms of C language, a new line is "\r\n". So, the left boundary is "User name:\r\n". Right boundary is a new line only - "\r\n".
So, the final code, which can be used for LoadRunner script correlation, is:
The result of its execution is:
In next articles, I will show different variants how to use web_reg_save_param LoadRunner function for script correlation. So, keep tracking carefully :)
- What are LoadRunner parameter and parameterization?
- Using Correlation in LoadRunner scripts - visual tutorial
- LoadRunner Correlation - How to capture an array of dynamic data with web_reg_save_param function
- How to perform basic operations on LoadRunner parameters?
- Using parameters in Loadrunner VuGen script
- All LoadRunner visual tutorials