用LR进行WEB测试,关联cookie出错!
比较长~,偶慢慢说~1,用LR录制一个内部网站的登录页面,用URL录制的。录制后并编辑的脚本如下:
vuser_init()
{
web_set_max_html_param_len("1024");
//对cookie进行的关联
// 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"
vuser_init.c(73): web_submit_data highest severity level was "ERROR", 3521 body bytes, 237 header bytes
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
Run-Time Settings file: "E:\fzhy\try_script\web_url\\default.cfg"
vuser_init.c(7): web_set_max_html_param_len was successful
vuser_init.c(11): Registering web_reg_save_param was successful
vuser_init.c(19): Redirecting "http://192.168.1.9/lab" (redirection depth=0)
vuser_init.c(19): To location "http://192.168.1.9/lab/"
vuser_init.c(19): Redirecting "http://192.168.1.9/lab/" (redirection depth=1)
vuser_init.c(19): To location "http://192.168.1.9/lab/login.jsp"
vuser_init.c(19): Redirecting "http://192.168.1.9/lab/login.jsp" (redirection depth=2)
vuser_init.c(19): To location "http://192.168.1.9/lab/LoginAction.do"
vuser_init.c(19): web_url was successful, 9471 body bytes, 915 header bytes, 56 chunking overhead bytes
vuser_init.c(28): web_concurrent_start was successful
vuser_init.c(29): Registering web_url was successful
vuser_init.c(35): Registering web_url was successful
vuser_init.c(42): web_concurrent_end was successful, 10487 body bytes, 316 header bytes
vuser_init.c(45): web_concurrent_start was successful
vuser_init.c(46): Registering web_url was successful
vuser_init.c(53): Registering web_url was successful
vuser_init.c(60): web_concurrent_end was successful, 109454 body bytes, 346 header bytes
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"
vuser_init.c(73): web_submit_data highest severity level was "ERROR", 3521 body bytes, 237 header bytes
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?
哪位大侠看明白并且发现问题了?在下不胜感激~~~~~~ 为什么要关联cookie
啊啊阿~斑竹~~~~
(脸红~),忘了说最初的问题,不关联cookie,还是会出现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"
vuser_init.c(73): web_submit_data highest severity level was "ERROR", 3521 body bytes, 237 header bytes
Abort was called from an action.
接上个~
所以我就做了个关联,如果不关联能够消除这个问题,哪当然就不用做了。。。。。汗。。。。。我是8是很迷糊。。。。。。。。 看server的log 你将record和replay的log详细的比较一下,看看为什么回放时server汇报500 error,
另外,你也看看错误的内容是什么,可能会给你一点启发。 一般COOKIE是不用关联,再检查一下脚本,是否有服务器返回的参数
哈哈哈~问题解决了~!!!
谢谢斑竹!!谢谢楼上的各位!!!!!其实解决的办法不是添加关联,大家说的对,不关联也可以.
我对比了录制的和回放的Client Request,把回放时header里面比录制里面缺少的内容,手工添加进去,运行OK啦!
代码如下:
vuser_init()
{
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);
//-----添加的代码
web_add_header("Accept_Encoding","gzip,deflate");
web_add_header("Accept_Language","zh-cn");
//--------------------
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);
再次对大家表示感谢!!!!!希望我的问题也能给别人一点提示! 其实在录制脚本时,选择录制header就可以解决这个问题 同样的问题,我选择了录制header,但还有错误.
recording options->advanced->headers,里面选择,没有错吧? 顶!!! 好文章 原帖由 soswhp 于 2007-5-16 10:14 发表 http://bbs.51testing.com/images/common/back.gif
同样的问题,我选择了录制header,但还有错误.
recording options->advanced->headers,里面选择,没有错吧?
有人知道原因吗?
顶,感谢
顶,感谢 学到了一种解决问题的思路 很好 这个要顶,可以借鉴解决问题 不错
页:
[1]