|
比较长~,偶慢慢说~
1,用LR录制一个内部网站的登录页面,用URL录制的。录制后并编辑的脚本如下:
vuser_init()
{
web_set_max_html_param_len("1024");
//对cookie进行的关联
// [WCSPARAM User_Cookie 62 xSGGhP3KdyMJGK53R66QMghW2sK1pp71CzF1LH3zVLJt4jcl5Dp!-882202093] Parameter {User_Cookie} created by Correlation Studio
web_reg_save_param("User_Cookie",
"LB=Set-Cookie: JSESSIONID=G",
"RB=;",
"Ord=1",
"RelFrameId=1",
"Search=Headers",
LAST);
web_url("lab",
"URL=http://192.168.1.9/lab",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTTP",
LAST);
web_concurrent_start(NULL);
web_url("css1.css",
"URL=http://192.168.1.9/lab/css/css1.css",
"Resource=1",
"Referer=http://192.168.1.9/lab/LoginAction.do",
LAST);
web_url("button-dl.gif",
"URL=http://192.168.1.9/lab/images/button-dl.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://192.168.1.9/lab/LoginAction.do",
LAST);
web_concurrent_end(NULL);
web_concurrent_start(NULL);
web_url("bg3.jpg",
"URL=http://192.168.1.9/lab/images/bg3.jpg",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://192.168.1.9/lab/LoginAction.do",
LAST);
web_url("loginbg.jpg",
"URL=http://192.168.1.9/lab/images/loginbg.jpg",
"Resource=1",
"RecContentType=image/jpeg",
"Referer=http://192.168.1.9/lab/LoginAction.do",
LAST);
web_concurrent_end(NULL);
//对当前关联的参数进行输出
lr_log_message("the init param is:%s", lr_eval_string("{User_Cookie}"));
web_submit_data("LoginAction.do",
"Action=http://192.168.1.9/lab/LoginAction.do",
"Method=POST",
"RecContentType=text/html",
"Referer=http://192.168.1.9/lab/LoginAction.do",
"Snapshot=t2.inf",
"Mode=HTTP",
ITEMDATA,
"Name=companyId", "Value=1", ENDITEM,
"Name=username", "Value={user}", ENDITEM,
"Name=password", "Value={passwd}", ENDITEM,
LAST);
2,运行到web_submit_data就报错了:vuser_init.c(73): Error -26612: HTTP Status-Code=500 (Internal Server Error) for "http://192.168.1.9/lab/LoginAction.do" [MsgId: MERR-26612]
vuser_init.c(73): web_submit_data highest severity level was "ERROR", 3521 body bytes, 237 header bytes [MsgId: MMSG-27178]
Abort was called from an action.
完整的输出如下:
Virtual User Script started
Starting action vuser_init.
Web Turbo Replay of LoadRunner 7.80.0 for WINXP; Web build 2271 [MsgId: MMSG-27143]
Run-Time Settings file: "E:\fzhy\try_script\web_url\\default.cfg" [MsgId: MMSG-27141]
vuser_init.c(7): web_set_max_html_param_len was successful [MsgId: MMSG-27182]
vuser_init.c(11): Registering web_reg_save_param was successful [MsgId: MMSG-27180]
vuser_init.c(19): Redirecting "http://192.168.1.9/lab" (redirection depth=0) [MsgId: MMSG-26694]
vuser_init.c(19): To location "http://192.168.1.9/lab/" [MsgId: MMSG-26693]
vuser_init.c(19): Redirecting "http://192.168.1.9/lab/" (redirection depth=1) [MsgId: MMSG-26694]
vuser_init.c(19): To location "http://192.168.1.9/lab/login.jsp" [MsgId: MMSG-26693]
vuser_init.c(19): Redirecting "http://192.168.1.9/lab/login.jsp" (redirection depth=2) [MsgId: MMSG-26694]
vuser_init.c(19): To location "http://192.168.1.9/lab/LoginAction.do" [MsgId: MMSG-26693]
vuser_init.c(19): web_url was successful, 9471 body bytes, 915 header bytes, 56 chunking overhead bytes [MsgId: MMSG-27175]
vuser_init.c(28): web_concurrent_start was successful [MsgId: MMSG-27182]
vuser_init.c(29): Registering web_url was successful [MsgId: MMSG-27180]
vuser_init.c(35): Registering web_url was successful [MsgId: MMSG-27180]
vuser_init.c(42): web_concurrent_end was successful, 10487 body bytes, 316 header bytes [MsgId: MMSG-27176]
vuser_init.c(45): web_concurrent_start was successful [MsgId: MMSG-27182]
vuser_init.c(46): Registering web_url was successful [MsgId: MMSG-27180]
vuser_init.c(53): Registering web_url was successful [MsgId: MMSG-27180]
vuser_init.c(60): web_concurrent_end was successful, 109454 body bytes, 346 header bytes [MsgId: MMSG-27176]
the init param is:yTWkDZQdLw6ncsYYHm1Xx1L9ZVgTpcybkffh2mJLRVQBDr7zMyb!-882202093 //关联参数的输出
vuser_init.c(73): Error -26612: HTTP Status-Code=500 (Internal Server Error) for "http://192.168.1.9/lab/LoginAction.do" [MsgId: MERR-26612]
vuser_init.c(73): web_submit_data highest severity level was "ERROR", 3521 body bytes, 237 header bytes [MsgId: MMSG-27178]
Abort was called from an action.
3,查看client request和server response
开始的client Request如下:
Header:
------------------------------------------
GET /lab HTTP/1.1
Accept: */*
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.3); .NET CLR 1.1.4322)
Connection: Keep-Alive
Host: 192.168.1.9
Body:
------------------------------------------
No Body was sent for this HTTP request.
开始的Server Response如下:
Header:
------------------------------------------
HTTP/1.1 200 OK
Date: Tue, 23 May 2006 08:59:02 GMT
Content-Length: 5459
Content-Type: text/html;charset=GBK
Set-Cookie: JSESSIONID=GyTXDbXrn8K9BwpyMvtTGXnybJzT6HLDPkJjV4JFqvSVXQpfH90q!-882202093; path=/
SubmitData的Client Request如下:
Header:
------------------------------------------
POST /lab/LoginAction.do HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Referer: http://192.168.1.9/lab/LoginAction.do
Accept: */*
Cache-Control: no-cache
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; (R1 1.3); .NET CLR 1.1.4322)
Connection: Keep-Alive
Host: 192.168.1.9
Cookie: JSESSIONID=GyTXDbXrn8K9BwpyMvtTGXnybJzT6HLDPkJjV4JFqvSVXQpfH90q!-882202093
Content-Length: 37
Body:
------------------------------------------
"companyId=1&username=lab&password=lab"
SubmitData的Server Response如下:
Header:
------------------------------------------
HTTP/1.1 500 Internal Server Error
Date: Tue, 23 May 2006 08:59:03 GMT
Content-Length: 3521
Content-Type: text/html
Set-Cookie: JSESSIONID=GyTXC1QgGv0tRxJCQQb7S7mCKfjJpnPRTN1jqyNqpW7GWdWprmLc!-882202093; path=/
Connection: Close
4,偶地问题:
a:为什么关联保存的参数中的cookie和SubmitData时Header里的cookie不一样?
b:明明SubmitData的cookie和最初的server端发送的cookie一样,为什么SubmitData还返回500错误?(用户名和密码是正确的哈~)
c:为什么SubmitData又返回一个cookie?
哪位大侠看明白并且发现问题了?在下不胜感激~~~~~~ |
|