Pages

Saturday, 1 April 2017

Random value from correlation parameter

web_reg_save_param("c_correlateParam",
                   "LB=value=\"",
                   "RB=\"",
                   "Ord=All",
                   LAST);

Hope you all are familiar with the most famous correlation function which is written above i.e. "web_reg_save_param". If you are not, read my old posts on correlation. Now, back to the topic, today I will show you how to pick a random value from the list of all captured correlation values through correlation function. 

Firstly, you need to give "All" as a value of "Ord" attribute of the correlation function so that all the values; match left and right boundary; can be captured. For your knowledge when you choose "Ord=All" then the correction parameter acts as an array. If you want to choose any specific value then you can append "_<number>" in the correlation parameter and use in the script. For example, if you need to pick 2nd value then the correlation parameter will be "c_correlateParam_2".

To pick the random value you need to use the following statement:
lr_save_string(lr_paramarr_random("c_correlateParam"),"randParam");

where:
lr_paramarr_random: This function returns a random value from the parameter array. The return value will be a 'String'. In the above example, a random value (string) will be picked from "c_correlateParam" array.
lr_save_string: This function is used to save a string into a parameter. In the above example, the random value (string) extracted by lr_paramarr_random will be saved in "randParam".
Now, you can use "randParam" as a parameter in the script which will pass a random value extracted from the list of captured correlation values.


14 comments:

  1. their r 2 drop down list (1. country , 2 state). Randomly we select country and states should be displayed as per the country selection.
    Could you please provide the details on this.

    Thanks in Advance,
    KR Reddy

    ReplyDelete
    Replies
    1. Hi Karthanparthi,

      While selecting the country, is there any request hitting the server? Or is it a JS call?

      Delete
    2. Hi Gagandeep could u please provide solutions for both the situations, even I had same question from very long time but no one helped

      Delete
    3. Hi Venkat,

      The first case is too easy to handle, because we can capture the response of the request; sent after selecting the country.

      But I never face the second situation, so no practical experience on it. I search in the google and found James comment on this case. But until I get such a real case scenario, I can't suggest any thing.

      James:
      The JavaScript variable would be in the local stack on the browser and not in the functional code for execution coming back. What you can do is collect the algorithm used to generate the ID and convert it to the language of your virtual user. You can then run the same code locally which would be executed in the browser and use the value as you see fit.

      But, it is likely far simpler then this....Record your Script twice. Vary as few elements as possible in the business process as this will place emphasis in the dynamic elements on the areas of session, state, time and any instance object identifiers, such as window ID, which may be changing from session to session. In greater than 95% of such cases reproducing the JavaScript algorithm in 'C' is not required as the identifier in question can be pulled from the return data stream.

      Delete
  2. Hi Gagan ,
    One small query ,can you please tell me, how to handle drop downs which are having same boundaries.If I want to correalte to one drop down I am getting all drop down values, even class names also same.I couldn't find any unique or vary boundary in this case how can I handle

    ReplyDelete
    Replies
    1. In such case, capture all the values under all the drop-downs using same correlation variable (say "c_drpDwn"), now check the place of required value in the source code (you can use view source code option in the browser to check the exact place of the required value).

      Let's try to understand with an example:
      Consider you have a page with 3 drop-down having same boundary value: Country, State, City.

      The country drop-down having 10 values (1st to 10th place)
      The state drop-down having 30 values (11th to 40th place)
      The city drop-down having 40 values (41th to 80th place)

      Now, you need to select 5th place country, 25th place state and 53th place city, then you can pass the value like this:
      For Country: c_drpDwn_5
      For State: c_drpDwn_25
      For City: c_drpDwn_53

      Delete
  3. One way is to use strtok() function, example is available in LR help file.

    ReplyDelete
    Replies
    1. Hi Sachin,

      String Token function is used to separate the value using delimiters; not to pick random value.

      Delete
  4. hi,
    could you please send performance tester roles and responsibility's to below email id:sbheemaiah406@gmail.com

    ReplyDelete
  5. hi,
    could you please send performance tester roles and responsibility's to below email:kiranklp.26@gmail.com

    ReplyDelete
  6. hi,
    could you please send performance tester roles and responsibility's to below email: choudharishivani14@gmail.com

    ReplyDelete
  7. Hi Shivani,

    This post may give you some clue:
    https://perfmatrix.blogspot.com/2017/05/performance-testing-vs-performance-engineering.html

    ReplyDelete