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:- web_reg_save_param("pID1Value", "LB=ID1\" value=\"", "RB=\"", LAST);
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).
An example: - 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:- User name:
- John Smith
- bla-bla-bla
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:- web_reg_save_param("pUserName", "LB=User name:\r\n", "RB=\r\n", LAST);
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 :)
Related articles:
- 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
15 comments:
Hi,
You have given a very good explanation about Correlation.Thanks a lot for all the good work.Can you please post information about Run-time settings , I mean optimal runtime settings to be used and why to use them.
Hi,
Good work there! I needed to know how do i compare the dates. I store the various dates in different parameter and want to compare if they are sorted in proper order. How do i do this?
2Anonymous (about dates):
Could you send your code? I will try to help you to process dates.
Hi,
Love your blog. I sit and read it for 2 whole days. I work with LaodRunner for 3 years and have a lot of experience, but still can find new stuff. I've started ot learn QTP and your articles are great help.
Keep going, Irena
Hi,
I am using LR 8.1 with web protocol (http)and recording web application based script. I recorded some flows very well and after correlation the script is executing very well. But in some another flows there are Ajax pages involment (web_custome_request ()). So how can I record/correlate the script based on ajax request through LR 8.1
2Shiven:
1. You can use Click & Script / AJAX protocol
2. You have to correlate a recorded script in the same way as usual page.
Hi,
this article will be very helpful to all who r learning loadrunner.
my question is "can we capture dynamic values at client side? if so will the same fn web_reg_save_param() will execute?
2Madhu:
What do you mean with "dynamic values at client side"?
Provide example.
hi,
Dynamic values r coming in the application in .swf files.However it is not affecting the application.and also Is there any diff in controller for "sequential_once" and "unique_once".
Hi, you are doing an AWESOME service to the world! One question I'm trying to make work...
How would you find "bla-bla_bla" in this example? Especially in the case where "John Smith" would return different values each page you opened.
Would you create a web_reg_find_param to find the "John Smith" value (as you did in your example), and then somehow use that parameter in the Left Boundary of your new web_reg_find_param request?
to Bradley Parker (September 19),
Since first/last names change, I would capture the internal string (first & last names + text).
In this case:
LR = "User name:"
RB = "/h1" (with angle brackets, I cannot past them here)
AS a result, it will capture the internal string "John Smith bla-bla-bla".
After that we should extract text (bla-bla-bla). For example, if it is a third word in a string, we can calculate words (or spaces) find the required text.
This is not difficult string manipulation.
hi,
Good Explanation, Can you please provide additional information about , how to capture one particular value if all the left and Right boundaries are same for all the cases?
@karunya,
In this case you should use "Ord" attribute of web_reg_save_param function.
It indicates the ordinal position or instance of the match.
Hi,
I stumbled on this nice site, good for me:). Thanks
Do you have info on how to capture Flex pages?
Thanks
A
Dear Readers!
Thank you very much for you comments!
Since this article was published more than one year ago, I've just disabled an adding of new comments for the article.
Post a Comment