使用LoadRunner过程中提交的订单使用变量来确认数据不会出现重复,不影响后续的业务流程,具体实现如下:
- Action()
- {
- int itera_num,rand_num,i;
- char i_name[24]="";
- char StrTable[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- for (i=0;i<=8;i++){
- rand_num=rand()%62;
- strncat(i_name,StrTable+rand_num,1);
- }
- lr_save_string(i_name,"i_name_value");
- lr_log_message("i_name== %s", i_name);
- //i_name_value即为可传入参数
- lr_log_message("i_name_value== %s", lr_eval_string("{i_name_value}"));
- web_submit_data("login",
- "Action=http://www.xxx.com/user/login",
- "Method=POST",
- "Mode=HTTP",
- "EncodeAtSign=YES",
- ITEMDATA,
- "Name=userName", "Value={i_name_value}", ENDITEM,
- "Name=password", "Value=111111", ENDITEM,
- "Name=captcha", "Value=", ENDITEM,
- LAST);
- }
参考文档:
http://blog.itpub.net/6110/viewspace-809063/
http://www.51testing.com/html/11/103211-129994.html