loadrunner获取返回值为乱码


找了很多方法,utf-8也设置了,还是不行,只有有转码方法了

web_reg_save_param("res2",
"LB=\"msg\":\"",
"RB=\"",
"Search=Body",
LAST);

lr_start_transaction("Web_注册_register_bean");

web_custom_request("web_custom_request",
"URL=http://{ip}/api/user/register",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=",
"Mode=HTTP",
"EncType=application/json",
"Body={\"username\":\"131{NewParam}\",\"password\": \"123456\"}",
LAST);


lr_convert_string_encoding(lr_eval_string("{res2}"),"utf-8",NULL,"msg");//将返回消息responseMsg值做编码转换

lr_output_message("转换编码后msg----%s",lr_eval_string("{msg}"));
if(strcmp(lr_eval_string("{msg}"),"注册成功")==0)

 

其实很简单,就是把原来返回的字符串res2,通过转码变成新的字符串msg.

再通过新的字符串msg与实际返回值进行比较


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM