LR十三:(查找函数+atoi)判断与(注册函数+strcmp函数)判断两种方法

loadrunner中接口判断的2中方法    如下:

1. ●查找函数web_reg_find() 

    ● atoi():将字符串转换为整型值 作比较  > 0

 1 Action()
 2 {
 3 //检查点函数+atoi函数
 4     web_reg_find("Search=Body",
 5         "SaveCount=fin_cnt",
 6         "Text=code":"0"",
 7         LAST);
 8 
 9     lr_start_transaction("get");
10 
11     web_url("get", 
12 
13     "URL=http://localhost:8080/pinter/com/getSku?id={num}",  
14 
15     LAST ); 
16 
17     if(atoi(lr_eval_string("{fin_cnt}")) >0 ){
18         
19         lr_end_transaction("get", LR_PASS);
20 
21     }else{
22         
23         lr_end_transaction("get", LR_FAIL);
24 
25     }
26 
27     return 0;
28 }

2. ●注册函数  web_reg_save_parameter

 ● strcmp函数     是把代码字符串转化为acll码,对应的数据进行比较。字符是否一致,这样判断的。

 1         
 2     // 注册函数,格式如下
 3     
 4         web_reg_save_param("参数名",
 5             "LB=左边界",
 6             "RB=右边界",
 7             "Ord=1",
 8             LAST);
 9  
10  
11      //"Ord=1", 可以是1,或其它条数  1 web_reg_save_param
 1 strcmp
 2 
 3 
 4 Action()
 5 {
 6 
 7 
 8 // 1,用关联函数把乱码数据保存下来
 9 // 2,编码转换,
10 web_add_header("Content-type", "application/json"); 
11 
12 web_reg_save_param("msg",
13 "LB=message":"",
14 "RB="",
15 "Ord=1",
16 LAST);
17 lr_start_transaction("post-2");
18 
19     web_custom_request("post", "Method=POST", 
20 
21     "URL=http://localhost:8080/pinter/com/register", 
22 
23     "Body={"userName":"{xxx}","password":"1234","gender":1,"phoneNum":"110","email":"beihe@163.com","address":"Beijing"}", 
24 
25     "TargetFrame=", 
26 
27     LAST ); 
28 
29 
30     lr_convert_string_encoding(lr_eval_string("{msg}"),  LR_ENC_UTF8 , LR_ENC_SYSTEM_LOCALE , "afterEncode");
31 
32 
33 
34 
35    if (strcmp(lr_eval_string("{afterEncode}") , "注册成功") == 0) {
36       lr_end_transaction("post-2", LR_PASS);
37   }else{
38       lr_end_transaction("post-2", LR_FAIL);
39   }
40 
41 
42   return 0;
43 }
原文地址:https://www.cnblogs.com/zhenyu1/p/10564192.html