Loadrunner : How to pass a correct correlation value to the request when the ordinal value and total count of correlated parameter is inconsistent?

Step 1: Token is the Correlation parameter which needs to be captured properly.

Step 2: Since the Total count of the Correlation parameter is inconsistent, we will capture all the values using "Ordinal=ALL",

web_reg_save_param_ex(
"ParamName=Token",
"LB=\"token\":\"",
"RB=\",\"theme\"",
"Ordinal=ALL",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/user*",
LAST);

web_url("ui", XXXXX, LAST);

Step 3: Save the total count of the correlated parameter to the variable tokencount.

tokencount = atoi(lr_eval_string("{Token_count}"));

Step 4: Pass each value one by one to the request using a for loop.

for (i=1; i <= tokencount; i++)

{

sprintf(crttoken, "{Token_%d}", (i));
lr_message(crttoken);

Step 5: Now I am passing the correlation value to the header. Similarly it can also be passed to the body of the request.

web_add_auto_header("__token__",
lr_eval_string(crttoken));

Step 6 : Check if the passed correlation parameter retrieves proper response using the web_reg_find function. (Here I am doing a negative check.)

web_reg_find("Text=You have Signed Off",
        "SaveCount=Count",
        LAST );

web_custom_request("getData", XXXX, LAST);

Step 7: Validate the text count, if the condition is true repeat the loop else break the loop.

if (atoi(lr_eval_string("{Count}")) > 0){

        lr_output_message( "Improper response retrived. Repeating the loop");
       
        }
       else{

         lr_output_message( "Proper response retrived. Exiting the loop" );
break;

}

}

Article by Vinoth Srinivasan