loadrunner判断接口返回

loadrunner判断前一个接口返回,执行第二个接口

Action()
{

/*关联获取接口返回结果,true或者false*/
web_reg_save_param("Text","LB=\"result\":","RB=,",LAST);
/*开始事务*/
lr_start_transaction("01_api_1");
web_custom_request("api_1", 
            "URL=https://webapp-n2.test.com/api/test",  
            "Method=GET", 
            "TargetFrame=", 
            "Resource=0", 
            "Snapshot=t2.inf",
            "RecContentType=text/html",  
            LAST);     

lr_end_transaction("01_api_1",LR_AUTO);

/*测试一下输出,用error只是因为会标红。。*/
lr_error_message(lr_eval_string("{Text}"));

/*判断第一个接口返回是否为true*/
if (strcmp(lr_eval_string("{Text}"),"true") == 0){
    lr_start_transaction("01_api_2");

        web_reg_find("Text=false",
            LAST);

        web_custom_request("api_2", 
            "URL=https://webapp-n2.test.com/api/test",  
            "Method=GET", 
            "TargetFrame=", 
            "Resource=0", 
            "Snapshot=t2.inf",
            "RecContentType=text/html",  
            LAST);

        lr_end_transaction("01_api_2",LR_AUTO);
        lr_output_message("第二接口完");
}else{

        lr_error_message("请求失败");
        return 0;
};
return 0;

}

文章目录
|