Assign Ordinal Count to File parameter

I am grabbing a dynamic array from JSON. LoadRunner is adding a number to each iteration of the array which is great however I need to have those numbers for later use.

Example:

    web_reg_save_param_ex(
        "ParamName=Id", 
        "LB/IC=Id\":",
        "RB/IC=,\"ResidentName\":\"",
        "Ordinal=ALL",
        SEARCH_FILTERS,
            "Scope=BODY",
        LAST);

This returns the following values:

id_1, id_2, id_3, id_4, id_5...etc

There is also a id_count of 20 that displays the total found

I would like to take this id_count of 20 and set that as the max of a count parameter.  I'll explain, the array is captured above. Each iteration of the test I want the {count} (below) to increase with the max count set to the id_count of 20 and have the count repeat in a cycle. 

    web_custom_request("Id", 
        "URL=MyWebsite/.../{Id}_{count}", 
        "Method=GET", 
        "Resource=0", 
        "Referer=", 
        "Snapshot=t18.inf", 
        "Mode=HTML", 
        LAST);

Each iteration would look like this

 "URL=MyWebsite/.../{Id}_1", 

"URL=MyWebsite/.../{Id}_2", 

"URL=MyWebsite/.../{Id}_3", 

"URL=MyWebsite/.../{Id}_4", 

Up to "URL=MyWebsite/.../{Id}_20", 

Then back to "URL=MyWebsite/.../{Id}_1", 

The best way I can see to accomplish this is to take 20 and parse it in a table. Any idea how to accomplish this? 

 

 

  • Verified Answer

    Hi

    Since you are taking about json, I assume you are using 12.53.

    For your needs I would have used a parameter array

      web_reg_save_param_ex(
            "ParamName=Id", 
            "LB/IC=Id\":",
            "RB/IC=,\"ResidentName\":\"",
            "Ordinal=ALL"
            "ResultParams=IDs",

            SEARCH_FILTERS,
                "Scope=BODY",
            LAST);

     

    Then you can in every iteration save this iteration value into a parameter. Something like this:

     

    // iteration_number should be a loadrunner parameter or a global counter
    // Remember that lr_paramarr_idx is 1 based
    lr_save_string(lr_paramarr_idx("IDs", iteration_number),"ID");

     

    All calls would then use the same
    "URL=">MyWebsite/.../{Id}",

    More info here:
    http://lrhelp.saas.hpe.com/en/12.53/help/function_reference/FuncRef.htm#c_vuser/etc/lrFr_c_ParameterArrays.htm?



    br /ola


    Please mark post as solved if your problems or questions is/are resolved.
    If this post was valuable to you, please consider kudo it.