actually i have a districts in my first drop-down list, i have to select that randomly by each user. now after district selection i have one more drop-down list with mandal divisions. there i don't know how many mandals are there for every district selected by each user. so in that mandal division i have to select last value of drop-down occurrences. so for example: 1st user selected chittoor district there 66 mandals available but i must have to select last one 66th mandal. 2nd user selected Vijayawada there 50 mandals available but i must have to select last one 50th mandal.
Asked
Active
Viewed 102 times
-3
-
You should [edit] your question and show the corresponding code, reduced to a complete minimal example. Where you don't know how to implement it, write comments about what you want to do. – Bodo Oct 08 '19 at 07:48
1 Answers
0
Sudhakar.
When you user capture a parameter called "PARAMETER" with ordinal=all, Loadrunner creates one parameter per ocurrence, called PARAMETER_1, PARAMETER_2... and a parameter called PARAMETER_count, which contains the number of ocurrences found. All you have to do is to read the value from that PARAMETER_count and to take the parameter in the place of this value. For example, if PARAMETER_count = 5, then the last ocurrence is saved in PARAMETER_5.
You can do this;
int i;
char buff[64];
i = atoi(lr_eval_string("{PARAM_count}"));
sprintf(buff,"{PARAM_%d}",i);
lr_log_message("%s",lr_eval_string(buff));
You can change the lr_log_message for lr_save_string, for example, and save it in another parameter.
BR,
Carlos.
-
Thanks Carlos, If I want to take before value of last occurrence. How to write that. – Sudhakar Oct 19 '19 at 04:57
-
Well, you only have to do "i-1", checking if i > 1 first: int i; char buff[64]; i = atoi(lr_eval_string("{PARAM_count}")); if (i > 1) sprintf(buff,"{PARAM_%d}", i-1); lr_log_message("%s",lr_eval_string(buff)); You can user the function lr_paramarr_idx instead using sprintf and a the buffer string variable "buf": int i; i = atoi(lr_eval_string("{PARAM_count}")); if (i > 1) lr_paramarr_idx("BEFORE_VALUE",i-1); lr_log_message("%s",lr_eval_string("{BEFORE_VALUE}")); – Carlos Lucena Herrera Oct 21 '19 at 06:43