Replay log的报错信息:
Action.c(30): Error: C interpreter run time error: Action.c (30):
compile通过,可是运行的时候就报错误信息.到第30行看:
if(strcmp(lr__string("{num}"),0)==0)
反复和资料上的对比,一模一样.为什么人家可以运行,猫猫却不可以.于是跑去CDSN下了一个函数大全来看:
// strcmp 比较 string1 和 string2 以确定字母排序的次序。
int strcmp ( const char *string1, const char *string2 );
于是猫猫试着将其改成:
if(strcmp(lr__string("{num}"),"0")==0)
Run succeed!
Virtual User Script started
Starting action vuser_init.
Web Turbo Replay of LoadRunner 9.0.0 for WINXP; WebReplay82 build 5727
Run-Time Settings file: "E:\Program Files\Mercury\LoadRunner\scripts\Shopping\\default.cfg"
vuser_init.c(12): web_url("index.jsp") was successful, 451 body bytes, 214 header bytes
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.
Starting action Action.
Action.c(7): Rendezvous LoginPoint
Action.c(10): Registering web_reg_find was successful
Action.c(15): Registered web_reg_find successful for "Text=购买" (count=5)
Action.c(15): web_submit_data("user.do") was successful, 1164 body bytes, 142 header bytes
用户名: admin
5
登陆成功
Ending action Action.
Starting action Shopping_Action.
Shopping_Action.c(7): Notify: Transaction "Shopping_Transaction" started.
Shopping_Action.c(9): web_url("merchandise.do") was successful, 1189 body bytes, 142 header bytes
Shopping_Action.c(18): Linking to "http://localhost:8080/shopping/merchandise.do?operate=toBag&id=2", Target Frame=""
Shopping_Action.c(18): web_link("购买") was successful, 1191 body bytes, 142 header bytes
Shopping_Action.c(25): Notify: Transaction "Shopping_Transaction" ended with "Pass" status (Duration: 0.3382).
Ending action Shopping_Action.
Starting action bag_Action.
bag_Action.c(6): web_url("bag.jsp") was successful, 1527 body bytes, 142 header bytes
Ending action bag_Action.
Starting action updateBag_Action.
updateBag_Action.c(6): web_submit_data("merchandise.do_2") was successful, 1544 body bytes, 142 header bytes
Ending action updateBag_Action.
Starting action clearBag_Action.
clearBag_Action.c(6): web_url("merchandise.do_3") was successful, 977 body bytes, 141 header bytes
Ending action clearBag_Action.
Ending iteration 1.
Starting iteration 2.
Starting action Action.
Action.c(7): Rendezvous LoginPoint
Action.c(10): Registering web_reg_find was successful
Action.c(15): Continuing after Error -26366: "Text=购买" not found for web_reg_find
Action.c(15): web_submit_data("user.do") highest severity level was "continue on error", 467 body bytes, 141 header bytes
Action.c(15): Continuing after error in Vuser script.
用户名: 123
0
登录失败
Ending action Action.
Starting action Shopping_Action.
Shopping_Action.c(7): Notify: Transaction "Shopping_Transaction" started.
Shopping_Action.c(9): web_url("merchandise.do") was successful, 1189 body bytes, 142 header bytes
Shopping_Action.c(18): Linking to "http://localhost:8080/shopping/merchandise.do?operate=toBag&id=2", Target Frame=""
Shopping_Action.c(18): web_link("购买") was successful, 1191 body bytes, 142 header bytes
Shopping_Action.c(25): Notify: Transaction "Shopping_Transaction" ended with "Pass" status (Duration: 0.1736).
Ending action Shopping_Action.
Starting action bag_Action.
bag_Action.c(6): web_url("bag.jsp") was successful, 1527 body bytes, 142 header bytes
Ending action bag_Action.
Starting action updateBag_Action.
updateBag_Action.c(6): web_submit_data("merchandise.do_2") was successful, 1544 body bytes, 142 header bytes
Ending action updateBag_Action.
Starting action clearBag_Action.
clearBag_Action.c(6): web_url("merchandise.do_3") was successful, 977 body bytes, 141 header bytes
Ending action clearBag_Action.
Ending iteration 2.
Ending Vuser...
Starting action vuser_end.
vuser_end.c(6): web_url("merchandise.do_4") was successful, 1164 body bytes, 142 header bytes
Ending action vuser_end.
Vuser Terminated.
----
脚本优化练习代码如下:
Action:
Shopping_Action: