How to select correct boundaries for web_reg_save_param LoadRunner function?

How to select correct boundaries for web_reg_save_param LoadRunner function?

I will explain and show - how to select correct boundaries for web_reg_save_param LoadRunner function.

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:
HTML source codeNote: I will refer to this example later.

  1. 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="
    And right boundary for web_reg_save_param is:
    • "
    See the solution:

    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).

    Right boundary can be found easily. Since abcde is followed by inverted comma, we can assign inverted comma to right boundary. So, right boundary is ".

    We have found left and right boundaries, so the final web_reg_save_param function is:

    1. 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:


  2. 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:

    1. User name:
    2. John Smith
    3. 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:

    1. web_reg_save_param("pUserName", "LB=User name:\r\n", "RB=\r\n", LAST);


    The result of its execution is:

web_reg_save_param is a kind of "must know" LoadRunner function. The principle is simple - it tries parse server's response and find a text, located between left and right boundaries.

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:


15 comments:

Anonymous said...

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.

Anonymous said...

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?

Dmitry Motevich said...

2Anonymous (about dates):
Could you send your code? I will try to help you to process dates.

Anonymous said...

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

Shiven said...

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

Dmitry Motevich said...

2Shiven:
1. You can use Click & Script / AJAX protocol
2. You have to correlate a recorded script in the same way as usual page.

madhu said...

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?

Dmitry Motevich said...

2Madhu:
What do you mean with "dynamic values at client side"?
Provide example.

madhu said...

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".

Bradley Parker said...

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?

Dmitry Motevich said...

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.

karunya said...

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?

Dmitry Motevich said...

@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.

Anonymous said...

Hi,
I stumbled on this nice site, good for me:). Thanks

Do you have info on how to capture Flex pages?

Thanks
A

Dmitry Motevich said...

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.