51Testing软件测试论坛
标题:
LR 参数化的值是中文时在测试传值乱码的中文后面会多出来字符导致失败
[打印本页]
作者:
游走记忆的湿巾
时间:
2015-10-28 21:52
标题:
LR 参数化的值是中文时在测试传值乱码的中文后面会多出来字符导致失败
如题,我在脚本里面加了将中文转成utf-8格式的编码,但是还是会报错,脚本回放的时候,已经显示a的值后面没有乱码字符了,但是100个name值中还是有30多个在测试时候失败 显示restr的值后面有乱码字符。
这个是什么原因呢 是开头的代码错误吗?
char *a;
lr_convert_string_encoding(lr_eval_string("{name}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString"); //此时skey是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中
a=lr_eval_string("{name}");
lr_save_string(a,"restr");
web_url("login",
"URL=http://192.168.68.21:56000/login",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/css/login.css", ENDITEM,
"Url=/css/images/log-bg.jpg", ENDITEM,
"Url=/css/images/login.png", ENDITEM,
"Url=/css/themes/default/images/loading.gif", ENDITEM,
"Url=/favicon.ico", "Referer=", ENDITEM,
"Url=http://s.pc.qq.com/pcmgr/zonedword/gjzonedword20150522.js", ENDITEM,
LAST);
web_submit_form("login_2",
"Snapshot=t2.inf",
ITEMDATA,
"Name=username", "Value=TEST001", ENDITEM,
"Name=password", "Value=123456", ENDITEM,
"Name=verifyCode", "Value=", ENDITEM,
EXTRARES,
"Url=/css/images/index-head-bg.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/js/My97DatePicker/skin/WdatePicker.css", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/combo_arrow.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/tabs_icons.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/blank.gif", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/panel_tools.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/searchbox_button.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=http://s.pc.qq.com/pcmgr/zonedword/gjzonedword20150522.js", "Referer=http://192.168.68.21:56000/checklist", ENDITEM,
"Url=/css/themes/default/images/accordion_arrows.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/js/My97DatePicker/skin/datePicker.gif", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/pagination_icons.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/images/check-working.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/themes/default/images/messager_icons.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
"Url=/css/images/check-finish.png", "Referer=http://192.168.68.21:56000/", ENDITEM,
LAST);
lr_rendezvous("拣货");
web_custom_request("pick.json",
"URL=http://192.168.68.21:56000/order/pick.json",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.68.21:56000/",
"Snapshot=t12.inf",
"Mode=HTML",
"EncType=application/json; charset=utf-8",
"Body=[{\"assignId\":\"{jfd}\",\"color\":\"{yx}\",\"fwd\":\"\",\"size\":\"{dx}\",\"barcode\":\"{txm}\",\"seqno\":\"00000\",\"cancelQty\":\"0\",\"serialNum\":\"{hh}\",\"serialName\":\"{restr}\",\"num\":\"1\",\"quoPrice\":\"680\",\"endPrice\":\"680\",\"allPrice\":\"680\",\"checkNum\":\"1\"}]",
LAST);
web_submit_data("findAssignmentList.json_3",
"Action=http://192.168.68.21:56000/order/findAssignmentList.json",
"Method=POST",
"RecContentType=application/json",
"Referer=http://192.168.68.21:56000/",
"Snapshot=t13.inf",
"Mode=HTML",
ITEMDATA,
"Name=page", "Value=1", ENDITEM,
"Name=rows", "Value=20", ENDITEM,
"Name=orderStatus", "Value=0,", ENDITEM,
"Name=payId", "Value=", ENDITEM,
"Name=orderId", "Value=", ENDITEM,
"Name=platformId", "Value=", ENDITEM,
"Name=payShopIds", "Value=", ENDITEM,
"Name=sellerIds", "Value=", ENDITEM,
"Name=fromDate", "Value=20151013", ENDITEM,
"Name=toDate", "Value=20151028", ENDITEM,
"Name=sessionId", "Value=", ENDITEM,
"Name=checkStatus", "Value=0,", ENDITEM,
LAST);
return 0;
作者:
jingzizx
时间:
2015-10-29 15:00
你每次使用restr打印出来看看,和报错比较一下
作者:
guikeyy
时间:
2015-11-4 18:17
转码后,参数名不在是"name"了,而是"UnicodeString";
lr_convert_string_encoding(lr_eval_string("{name}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"tname");
lr_save_string(lr_eval_string("{tname}"),"tname");
web_convert_param("tname","SourceString={tname}","SourceEncoding=PLAIN","TargetEncoding=URL",LAST);
比如上面这样,转码后,调用转码后的变量应该是"tname"
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2