当我们使用LR进行脚本录制的时候,会遇到录制好的脚本的乱码问题。那么应该如何解决这样的问题呢?
下面就讲讲我们采用的方法。
一般情况下遇到的乱码情况如下(下面是录制好的脚本):
Action()
{
web_add_auto_header("Accept-Language",
"zh-cn");
web_set_max_html_param_len("1024");
web_reg_save_param("Siebel_Analytic_ViewState4",
"LB/IC=ViewState"value="",
"RB/IC="",
"Ord=1",
"RelFrameId=1",
"Search=Body",
LAST);
web_url("login.aspx",
"URL=http://192.168.31.16/it/login/login.aspx",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTTP",
LAST);
web_url("lo.jpg",
"URL=http://192.168.31.16/it/Images/lo.jpg",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://192.168.31.16/it/login/login.aspx",
"Snapshot=t2.inf",
LAST);
lr_start_transaction("login");
lr_rendezvous("login");
lr_think_time(66);
web_submit_data("login.aspx_2",
"Action=http://192.168.31.16/it/login/login.aspx",
"Method=POST",
"RecContentType=text/html",
"Referer=http://192.168.31.16/it/login/login.aspx",
"Snapshot=t3.inf",
"Mode=HTTP",
ITEMDATA,
"Name=__EVENTTARGET","Value=LinkButton1", ENDITEM,
"Name=__EVENTARGUMENT","Value=", ENDITEM,
"Name=__VIEWSTATE","Value={Siebel_Analytic_ViewState4}", ENDITEM,
"Name=__EVENTVALIDATION","Value=/wEWBQL1zYCUCgKM54rGBgKvruq2CALQ75rvDALM9PumD5njSJlIKihzfQ/Pj8sgG2WSShWtI6C+mvJXxum/HZtf",ENDITEM,
"Name=UserName","Value=xuhongiyng", ENDITEM,
"Name=pd", "Value=123",ENDITEM,
LAST);
lr_start_transaction("login");
web_submit_data("login.aspx_3",
"Action=http://192.168.31.16/it/login/login.aspx",
"Method=POST",
"RecContentType=text/html",
"Referer=http://192.168.31.16/it/login/login.aspx",
"Snapshot=t4.inf",
"Mode=HTTP",
ITEMDATA,
"Name=__EVENTTARGET","Value=LinkButton1", ENDITEM,
"Name=__EVENTARGUMENT","Value=", ENDITEM,
"Name=__VIEWSTATE","Value={Siebel_Analytic_ViewState4}", ENDITEM,
"Name=__EVENTVALIDATION","Value=/wEWBQL1zYCUCgKM54rGBgKvruq2CALQ75rvDALM9PumD5njSJlIKihzfQ/Pj8sgG2WSShWtI6C+mvJXxum/HZtf",ENDITEM,
"Name=UserName","Value=xuhongying", ENDITEM,
"Name=pd", "Value=123",ENDITEM,
LAST);
web_concurrent_start(NULL);
web_url("Master.css",
"URL=http://192.168.31.16/it/Styles/Master.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t5.inf",
LAST);
web_url("jquery-1.4.4.min.js",
"URL=http://192.168.31.16/it/JS/jquery-1.4.4.min.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t6.inf",
LAST);
web_url("jquery-ui-1.8.7.custom.min.js",
"URL=http://192.168.31.16/it/JS/jquery-ui-1.8.7.custom.min.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t7.inf",
LAST);
web_url("jquery.autocomplete.js",
"URL=http://192.168.31.16/it/JS/jquery.autocomplete.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t8.inf",
LAST);
web_url("jquery-ui-1.8.7.custom.css",
"URL=http://192.168.31.16/it/JS/redmond/jquery-ui-1.8.7.custom.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t9.inf",
LAST);
web_url("jquery.autocomplete.css",
"URL=http://192.168.31.16/it/Styles/jquery.autocomplete.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t10.inf",
LAST);
web_url("Common.css",
"URL=http://192.168.31.16/it/Styles/Common.css",
"Resource=1",
"RecContentType=text/css",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t11.inf",
LAST);
web_url("validator.js",
"URL=http://192.168.31.16/it/JS/validator.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t12.inf",
LAST);
web_url("line.jpg",
"URL=http://192.168.31.16/it/Images/line.jpg",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t13.inf",
LAST);
web_concurrent_end(NULL);
web_concurrent_start(NULL);
web_url("user.png",
"URL=http://192.168.31.16/it/Images/user.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t14.inf",
LAST);
web_url("password.png",
"URL=http://192.168.31.16/it/Images/password.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t15.inf",
LAST);
web_url("top1_03.png",
"URL=http://192.168.31.16/it/Images/top1_03.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t16.inf",
LAST);
web_url("top1_01.png",
"URL=http://192.168.31.16/it/Images/top1_01.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t17.inf",
LAST);
web_url("top1_02.png",
"URL=http://192.168.31.16/it/Images/top1_02.png",
"Resource=1",
"RecContentType=image/png",
"Referer=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Snapshot=t18.inf",
LAST);
web_concurrent_end(NULL);
lr_think_time(19);
web_reg_find("Search=Body",
"TextPfx=xu",
"TextSfx=ying",
LAST);
web_url("寰呭姙椤圭洰",
"URL=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.168.31.16/it/login/login.aspx",
"Snapshot=t19.inf",
"Mode=HTTP",
LAST);
lr_think_time(5);
web_url("寰呭姙椤圭洰_2",
"URL=http://192.168.31.16/it/Pages/UnProcessList.aspx",
"Resource=0",
"RecContentType=text/html",
"Referer=http://192.168.31.16/it/login/login.aspx",
"Snapshot=t20.inf",
"Mode=HTTP",
LAST);
lr_think_time(16);
web_url("Login.aspx",
"URL=http://192.168.31.16/it/Login/Login.aspx",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t21.inf",
"Mode=HTTP",
LAST);
lr_end_transaction("login", LR_AUTO);
return 0;
}
针对上面的中文乱码,可以采用如下设置:
解决方案一:脚本录制好后-》在TOOL-》RECORDING OPTIONS -》ADVANCED -》SUPPORTCHARSET 勾选UTF-8即
可。
解决方案二:在IE-->属性-->高级选项里的最后一项,总是以UTF-8发送请求前面的勾去掉,关闭浏览器.再录制试试
解决方案三:新建脚本--->选择协议(Http)-->选项-->高级-->选择“支持字符集”并点选“UTF-8”
解决方案四:在回放脚本之前:Vuser-->运行时设置-->浏览器-->浏览器仿真-->更改-->使用浏览器-->语言下来选择“中文(中国)”
下面再推荐两种解决方法:
a) Go to Vugen-> Tools -> Recording Options-> Advanced