Hi Bharath,
To achieve it, besides using parameterization, you also need to write some custom C code to randomize the total selected products for each Vuser and concatenate all selected product codes (from paramter file) into a new char string.
First, add a new parameter and edit the assosiated file in notepad with all valid product codes. Choose random for select next row field.
Second, write some script like below to calculate the dynamic selected product codes, and save the result into a new parameter so that you can easily reference it in your original script.
Action() { int i, n = 1; int MAX_PRODUCT_NUM = 4; char szProductCodes[1024]; srand(time(NULL)); n = rand() % MAX_PRODUCT_NUM + 1; szProductCodes[0] = '\0'; for(i = 0; i < n; i++) { char *product = lr_eval_string("{ProductCodeParam}"); if(!strstr(szProductCodes, product)) { //ONLY add the product if it's not selected before strcat(szProductCodes, product); if(i < n - 1) strcat(szProductCodes, "#"); } } lr_save_string(szProductCodes, "SelectedProductCodes"); //save it to a new parameter so that you can easily refer to it in web API using {SelectedProductCodes} lr_output_message("selected %d products: %s", n, lr_eval_string("{SelectedProductCodes}")); return 0; }
Third, change the hardcoded product code part in your recorded script with the parameter usage: {SelectedProductCodes}
Please refer to attached script for a complete example.
Regards,
Tedy