loadrunner关联取参--响应值unicode编码处理过
背景:做电商提交订单,需要获取订单号,然后进行支付、状态变更等操作
submitOrder() { lr_think_time(1); /* 提交订单 */ /* specsId:规格ID,hyh_goods_specs phone userkey:hyh_user表中phone和user_key2 登陆用户 userAddressId:hyh_user_address表中ID */ web_reg_save_param("order", "LB=orderNo%22%3A%22", "RB=%22%7D", "NotFound=ERROR", "Search=All", LAST); web_custom_request("appapi_13", "URL={url}/appapi?act=submitorder", "Method=POST", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t103.inf", "Mode=HTTP", "EncType=application/json; charset=utf-8", "Body={'payType':'alipay','versionCode':'3.0.6','yqhCheck':'0','specsId':'516','goodsId':'100446','phone':'{phone}','comment':'','count':'1','userkey':'{userkey}','couponId':'0','userAddressId':'{addressid}'}", LAST); lr_output_message("the output is %s",lr_eval_string("{order}")); }
成功后响应内容应该是:
{"msg":2,"msgText":"订单提交成功","orderNo":"201611151660688"} 未转码前的
实际的响应结果转码unicode
%7b%22msg%22%3a2%2c%22msgText%22%3a%22%e8%ae%a2%e5%8d%95%e6%8f%90%e4%ba%a4%e6%88%90%e5%8a%9f%22%2c%22orderNo%22%3a%22201611151660688%22%7d
看到这样的,可以用站长工具进行解码:
http://tool.chinaz.com/tools/urlencode.aspx
LR中关联参数取值,左右边界可直接放转码后的结果
如果您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】
本文版权归作者和博客园共有,欢迎转载