TA的每日心情 | 奋斗 2019-3-7 09:49 |
---|
签到天数: 133 天 连续签到: 1 天 [LV.7]测试师长
|
本帖最后由 thirfing 于 2013-5-7 16:25 编辑
Problem Description: How to randomly select parameters saved by web_reg_save_param
How to randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL.
--------------------------------------------------------------------------------
Solution: Use custom C coding to randomly select parameters
You can randomly select parameters saved by web_reg_save_param with the attribute ORD = ALL by using custom C coding in your script.
EXAMPLE:
Action1()
{
char* temp,i;
int j;
//create a parameter with the desired boundaries
web_reg_save_param ("pram", "NOTFOUND=ERROR", "LB=left_b","RB=right_b" , "ORD=ALL", LAST );
//call to the URL
web_url("HomePage", "URL=<Your_URL>", LAST);
//get the total number of occurance captured
j = atoi(lr_eval_string("{pram_count}"));
//generate a random number between 1 to j
sprintf(&i, "%d", ( 1 + rand() % j));
//save the random number as a parameter - random_value
lr_save_string(&i, "random_value");
//get the value of parameter x (generated via random number )
temp = lr_eval_string(lr_eval_string("{pram_{random_value}}"));
//save the data as a parameter - random_param
lr_save_string(temp, "random_param");
//call a random URL
web_url("Example", "URL={random_param}", LAST);
return 0;
} |
|