51Testing软件测试论坛
标题:
loadrunner获取服务器信息后,为什么第一循环没有输出服务返回信息
[打印本页]
作者:
yuejing127
时间:
2012-5-18 11:01
标题:
loadrunner获取服务器信息后,为什么第一循环没有输出服务返回信息
本帖最后由 yuejing127 于 2012-5-18 11:10 编辑
想用loadrunner进行接口测试,提交数据后想得到服务器的返回信息并且输出。我录制的脚步如下(自己手动添加的web_reg_save_param函数来获取服务器返回的页面信息):
Action()
{
web_url("vehicleInsurance",
"URL=http://ydkh.ab95569.com/test/vehicleInsurance/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"URL=/favicon.ico", ENDITEM,
LAST);
web_url("favicon.ico",
"URL=http://www.live.com/favicon.ico",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
lr_rendezvous("jingsuan");
lr_start_transaction("Calculate_Time");
lr_think_time(60);
web_reg_save_param("response",
"LB/IC=",
"RB/IC=",
"Search=Body",
LAST);
lr_output_message(lr_eval_string("{response}"));
web_reg_find("Text=\"errorCode\":\"200\",\"errorMessage\":\"",
"Search=Body",
LAST);
web_submit_data("requestController.do",
"Action=http://ydkh.ab95569.com/test/vehicleInsurance/requestController.do?method=calculatev6",
"Method=POST",
"TargetFrame=",
"RecContentType=text/plain",
"Referer=http://ydkh.ab95569.com/test/vehicleInsurance/",
"Snapshot=t3.inf",
"Mode=HTML",
ITEMDATA,
"Name=token", "Value={token}", ENDITEM,
"Name=tempAppId", "Value=", ENDITEM,
"Name=appObj", "Value={\r\n"
"\t\"packageType\":\"A\",\r\n"
"\t\"inspection\":\"1\",\r\n"
"\t\"beginTime\":\"2012-05-30\",\r\n"
"\t\"depCode\":\"02000104\",\r\n"
"\t\"depAttr\":\"014015\",\r\n"
"\t\"grantDepCode\":\"ZQ02000100\",\r\n"
"\t\"userInfo\":{\r\n"
"\t\t\"101\":[\r\n"
"\t\t\t{\r\n"
"\t\t\t\t\"name\":\"鍗僵鐞\xB3\",\r\n"
"\t\t\t\t\"licenseType\":\"01\",\r\n"
"\t\t\t\t\"license\":\"420602198308201019\",\r\n"
"\t\t\t\t\"mobile\":\"13910657412\",\r\n"
"\t\t\t\t\"address\":\"娴欐睙鐪佹澀宸炲競鎷卞鍖\xBA\",\r\n"
"\t\t\t\t\"zipcode\":\"111111\",\r\n"
"\t\t\t\t\"refId\":0\r\n"
"\t\t\t}\r\n"
"\t\t],\r\n"
"\t\t\"102\":[\r\n"
"\t\t\t{\r\n"
"\t\t\t\t\"relationship\":\"601005\",\r\n"
"\t\t\t\t\"name\":\"娉㈡稕\",\r\n"
"\t\t\t\t\"licenseType\":\"01\",\r\n"
"\t\t\t\t\"license\":\"111111111111111\",\r\n"
"\t\t\t\t\"mobile\":\"13910657412\",\r\n"
"\t\t\t\t\"address\":\"娴欐睙鐪佹澀宸炲競鎷卞鍖\xBA\",\r\n"
"\t\t\t\t\"zipcode\":\"111111\"\r\n"
"\t\t\t}\r\n"
"\t\t],\r\n"
"\t\t\"201\":[\r\n"
"\t\t\t{\r\n"
"\t\t\t\t\"name\":\"瑕冨獩濯\x9B\",\r\n"
"\t\t\t\t\"licenseType\":\"01\",\r\n"
"\t\t\t\t\"license\":\"111111111111111\",\r\n"
"\t\t\t\t\"address\":\"鍖椾含甯傛湞闃冲尯鍥借锤鍙屽瓙搴\xA7\",\r\n"
"\t\t\t\t\"zipcode\":\"100052\"\r\n"
"\t\t\t}\r\n"
"\t\t]\r\n"
"\t},\r\n"
"\t\"vehicleInfo\":{\r\n"
"\t\t\"lcnNo\":\"\",\r\n"
"\t\t\"engNo\":\"{engNo}\",\r\n"
"\t\t\"regTime\":\"2011-10\",\r\n"
"\t\t\"carFrameNo\":\"{CarFrameNo}\",\r\n"
"\t\t\"useYearCode\":\"373001\",\r\n"
"\t\t\"usageCode\":\"374001\",\r\n"
"\t\t\"seatNum\":5,\r\n"
"\t\t\"exhaust\":2.4,\r\n"
"\t\t\"price\":249500,\r\n"
"\t\t\"productPlace\":\"2\",\r\n"
"\t\t\"vehicleType\":\"365001\",\r\n"
"\t\t\"isNew\":\"1\",\r\n"
"\t\t\"vehicleId\":\"JYD1040SHT\",\r\n"
"\t\t\"vehicleName\":\"鍒厠SGM7242ATA杞胯溅\",\r\n"
"\t\t\"brandId\":\"BKA\",\r\n"
"\t\t\"brandName\":\"鍒厠\",\r\n"
"\t\t\"familyId\":\"MK0677\",\r\n"
"\t\t\"familyName\":\"鍚涜秺\",\r\n"
"\t\t\"color\":\"鐧\xBD\",\r\n"
"\t\t\"claimTimes\":\"01\",\r\n"
"\t\t\"travelProvinceCode\":\"110000\",\r\n"
"\t\t\"travelProvince\":\"鍖椾含甯\x82\",\r\n"
"\t\t\"travelCityCode\":\"110100\",\r\n"
"\t\t\"travelCity\":\"鍖椾含甯\x82\",\r\n"
"\t\t\"fuelType\":\"A\",\r\n"
"\t\t\"glassType\":\"303011001\",\r\n"
"\t\t\"derivationPaperType\":\"01\",\r\n"
"\t\t\"derivationPaperCode\":\"135\",\r\n"
"\t\t\"derivationPaperTime\":\"2011-05-01\"\r\n"
"\t},\r\n"
"\t\"insuranceList\":[\r\n"
"\t\t{\r\n"
"\t\t\t\"insuranceType\":\"0326\",\r\n"
"\t\t\t\"items\":[\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030001\",\r\n"
"\t\t\t\t\t\"premium\":10000.00,\r\n"
"\t\t\t\t\t\"iop\":\"1\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t},\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030004\",\r\n"
"\t\t\t\t\t\"premium\":0,\r\n"
"\t\t\t\t\t\"iop\":\"0\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t},\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030006\",\r\n"
"\t\t\t\t\t\"premium\":249500,\r\n"
"\t\t\t\t\t\"iop\":\"1\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t},\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030009\",\r\n"
"\t\t\t\t\t\"premium\":10000.00,\r\n"
"\t\t\t\t\t\"iop\":\"1\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t},\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030018\",\r\n"
"\t\t\t\t\t\"premium\":50000,\r\n"
"\t\t\t\t\t\"iop\":\"1\",\r\n"
"\t\t\t\t\t\"premiumLevel\":\"306006004\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t},\r\n"
"\t\t\t\t{\r\n"
"\t\t\t\t\t\"policyCode\":\"030061\",\r\n"
"\t\t\t\t\t\"premium\":249500.00,\r\n"
"\t\t\t\t\t\"iop\":\"1\",\r\n"
"\t\t\t\t\t\"flag\":\"1\"\r\n"
"\t\t\t\t}\r\n"
"\t\t\t]\r\n"
"\t\t}\r\n"
"\t]\r\n"
"}\r\n"
"\t\t", ENDITEM,
LAST);
lr_end_transaction("Calculate_Time", LR_AUTO);
return 0;
}
作者:
yuejing127
时间:
2012-5-18 11:01
本帖最后由 yuejing127 于 2012-5-18 11:11 编辑
回复
1#
yuejing127
回放脚本时,设置action运行次数为两次,输出的log信息如下:
Virtual User Script started at : 2012-05-18 10:10:55
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0.0 for WINXP; build 8859 (Aug 18 2010 20:14:31) [MsgId: MMSG-27143]
Run Mode: HTML [MsgId: MMSG-26000]
Run-Time Settings file: "D:\HP\LoadRunner\scripts\calculate0326_update\\default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(4): web_url("vehicleInsurance") was successful, 3686 body bytes, 297 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(17): Redirecting "http://www.live.com/favicon.ico" (redirection depth is 0) [MsgId: MMSG-26694]
Action.c(17): To location "https://home.live.com/" [MsgId: MMSG-26693]
Action.c(17): Redirecting "https://home.live.com/" (redirection depth is 1) [MsgId: MMSG-26694]
Action.c(17): To location "https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1337307053&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fhome.live.com%2F&lc=2052&id=251248&cbcxt=hom&mkt=zh-CN" [MsgId: MMSG-26693]
Action.c(17): web_url("favicon.ico") was successful, 12596 body bytes, 1701 header bytes [MsgId: MMSG-26386]
Action.c(27): Rendezvous jingsuan
Action.c(31): Notify: Transaction "Calculate_Time" started.
Action.c(36): Registering web_reg_save_param was successful [MsgId: MMSG-26390]
Action.c(42): {response}
Action.c(45): Registering web_reg_find was successful [MsgId: MMSG-26390]
Action.c(49): Registered web_reg_find successful for "Text="errorCode":"200","errorMessage":"" (count=1) [MsgId: MMSG-26364]
Action.c(49): web_submit_data("requestController.do") was successful, 285 body bytes, 282 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(182): Notify: Transaction "Calculate_Time" ended with "Pass" status (Duration: 14.8807 Wasted Time: 0.0280).
Ending action Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(4): web_url("vehicleInsurance") was successful, 3686 body bytes, 297 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(17): Redirecting "http://www.live.com/favicon.ico" (redirection depth is 0) [MsgId: MMSG-26694]
Action.c(17): To location "https://home.live.com/" [MsgId: MMSG-26693]
Action.c(17): Redirecting "https://home.live.com/" (redirection depth is 1) [MsgId: MMSG-26694]
Action.c(17): To location "https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1337307073&rver=6.1.6206.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fhome.live.com%2F&lc=2052&id=251248&cbcxt=hom&mkt=zh-CN" [MsgId: MMSG-26693]
Action.c(17): web_url("favicon.ico") was successful, 12841 body bytes, 1701 header bytes [MsgId: MMSG-26386]
Action.c(27): Rendezvous jingsuan
Action.c(31): Notify: Transaction "Calculate_Time" started.
Action.c(36): Registering web_reg_save_param was successful [MsgId: MMSG-26390]
Action.c(42): {"errorCode":"200","errorMessage":"","insuranceList":[{"insuranceType":"0326","id":17329,"insuranceNo":"0020003262012002072","calcFlag":"1","items":[{"flag":"1","insuranceId":17329,"iop":"1","payment":42.44,"policyCode":"030001","premium":10000},{"flag":"1","insuranceId":17329,"iop":"0","payment":376.03,"policyCode":"030004","premium":0},{"flag":"1","insuranceId":17329,"iop":"1","payment":3471.1,"policyCode":"030006","premium":249500},{"flag":"1","insuranceId":17329,"iop":"1","payment":107.64,"policyCode":"030009","premium":10000},{"flag":"1","insuranceId":17329,"iop":"1","payment":628.24,"policyCode":"030018","premium":50000,"premiumLevel":"306006004"},{"flag":"1","insuranceId":17329,"iop":"1","payment":1335.44,"policyCode":"030061","premium":249500}],"payment":5960.89}],"payment":5960.89}
Action.c(45): Registering web_reg_find was successful [MsgId: MMSG-26390]
Action.c(49): Registered web_reg_find successful for "Text="errorCode":"200","errorMessage":"" (count=1) [MsgId: MMSG-26364]
Action.c(49): web_submit_data("requestController.do") was successful, 286 body bytes, 282 header bytes, 12 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(182): Notify: Transaction "Calculate_Time" ended with "Pass" status (Duration: 8.4227 Wasted Time: 0.0403).
Ending action Action.
Ending iteration 2.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
第一次运行没有输出服务器信息,只输出了{reponse}的字样
第二次运行才输出了服务器返回的相关信息!
请各位大侠指点迷津啊~急啊!跪谢
作者:
yuejing127
时间:
2012-5-18 11:05
本帖最后由 yuejing127 于 2012-5-18 11:12 编辑
回复
2#
yuejing127
服务器返回的界面如图所示,或者谁有更好的方法可以获取到这个页面的信息并且输出来吗??
[attach]79083[/attach[attach]79084[/attach]]
作者:
yuejing127
时间:
2012-5-18 15:23
怎么没人解答啊,紧急求救啊~
作者:
thirfing
时间:
2012-5-21 16:48
lr_output_message(lr_eval_string("{response}"));
移至web_submit_data之后?
作者:
yolanda_ji
时间:
2012-6-4 08:54
你可以先询问一下你们开发,那些是动态数据
作者:
yolanda_ji
时间:
2012-6-4 08:58
好像“iop”、"payment"、"policyCode"、"premium"都是动态数据,对吗?
作者:
qvbfnsc
时间:
2012-6-4 09:19
web_reg_save_param("response",
这个语句只是申明一下变量,要在他后面的语句执行完成后才能取到具体数值的, lr_output_message(lr_eval_string("{response}"));应放到web_submit_data之后
作者:
edisonzhang
时间:
2012-6-4 09:45
web_reg_save_param("response",
"LB/IC=",
"RB/IC=",
"Search=Body",
LAST);
明显的位置不对撒
作者:
夏日摸摸茶
时间:
2012-6-4 20:52
lr_start_transaction("Calculate_Time");
lr_think_time(60);
web_reg_save_param("response",
"LB/IC=",
"RB/IC=",
"Search=Body",
LAST);
思考时间不能放在事物里面的
作者:
夏日摸摸茶
时间:
2012-6-4 20:53
输出位置放错了,相当于第一次输出response,第二次迭代时输出的是第一次迭代时获取的参数了。。。
作者:
jj_ljw
时间:
2012-6-5 09:21
没发现你在后面用response这个参数,那为啥要做关联呢
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2