Highlighted
Trusted Contributor.
Trusted Contributor.
1326 views

Assign Ordinal Count to File parameter

Jump to solution

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=http://MyWebsite/api/facility/residents/{Id}_{count}", 
        "Method=GET", 
        "Resource=0", 
        "Referer=", 
        "Snapshot=t18.inf", 
        "Mode=HTML", 
        LAST);

Each iteration would look like this

 "URL=http://MyWebsite/api/facility/residents/{Id}_1", 

"URL=http://MyWebsite/api/facility/residents/{Id}_2", 

"URL=http://MyWebsite/api/facility/residents/{Id}_3", 

"URL=http://MyWebsite/api/facility/residents/{Id}_4", 

Up to "URL=http://MyWebsite/api/facility/residents/{Id}_20", 

Then back to "URL=http://MyWebsite/api/facility/residents/{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? 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Assign Ordinal Count to File parameter

Jump to solution

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=http://MyWebsite/api/facility/residents/{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.

 

 

 

.

View solution in original post

Tags (1)
1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Assign Ordinal Count to File parameter

Jump to solution

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=http://MyWebsite/api/facility/residents/{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.

 

 

 

.

View solution in original post

Tags (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.