51Testing软件测试论坛
标题:
LoadRunner保存服务器返回字符串问题求助,项目紧急,在线等回复!
[打印本页]
作者:
dxf_michael
时间:
2009-1-6 09:25
标题:
LoadRunner保存服务器返回字符串问题求助,项目紧急,在线等回复!
编了一段脚本代码,想要将服务器的返回中一个字符串保存下来,但是不知道为什么,好像一直无法保存,运行也没报错,字符串变量一直是空的。
Action()
{
char UserToken[32];
web_reg_save_param("UserToken",
"LB=CTCGetAuthInfo('",
"RB=')",
LAST);
web_url("index.jsp",
"URL=http://10.42.109.12:8080/iptvepg/platform/index.jsp?UserID=test&Action=Login",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
lr_output_message("UserToken=%s",lr_eval_string(UserToken));
web_add_cookie
return 0;
}
服务器返回的页面,要保存的是红色部分:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=F4CA2CA519373555017DCD91A14E43E6; Path=/iptvepg
Content-Type: text/html;charset=GBK
Content-Length: 1308
Date: Tue, 06 Jan 2009 17:00:15 GMT
<!-- get encrypt token -->
<html>
<head>
<script language="javascript" type="">
function DoAuth()
{
if (typeof(Authentication) == "object" && "CTCGetAuthInfo" in Authentication)
{
document.authform.Authenticator.value = Authentication.CTCGetAuthInfo([email=]'
@@Q31EeaLZE@nq0QDPvlx6ZddBSQe5yr
'[/email]);
document.authform.submit();
}
else
{
// handle error. "Authentication is not supported by current browser"
window.location = "/iptvepg" + "/errorHandler.jsp?" + "tips" + "=EPGActM0301";
}
}
</script>
</head>
<body bgcolor="#000000" >
<!-- loading page -->
<div style="left:120; top:390;width:400;height:32; position:absolute">
<center>
<font color="#ffffff" size="6"><b>正在进入,请稍候…</b></font><!--???????????????ò...-->
</center>
</div>
<form action="auth.jsp" name="authform" method="post">
<input type="hidden" name="UserID" value="test">
<input type="hidden" name="Authenticator" value="">
<input type="hidden" name="StbIP" value="10.42.119.77">
<input type="hidden" name="LastTermno" value="2">
</form>
</body>
</html>
loadrunner运行输出,UserToken始终没有值:
Virtual User Script started
Starting action vuser_init.
Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
Run-Time Settings file: "D:\Program Files\Mercury\LoadRunner\scripts\http\\default.cfg" [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(5): Registering web_reg_save_param was successful [MsgId: MMSG-26390]
Action.c(9): web_url("index.jsp") was successful, 1307 body bytes, 214 header bytes [MsgId: MMSG-26386]
Action.c(18): UserToken=
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
作者:
dxf_michael
时间:
2009-1-6 09:32
等待高手的出现!
作者:
whyleave
时间:
2009-1-6 09:39
lr_output_message("UserToken=%s",lr_eval_string(UserToken));
改成 lr_output_message("UserToken=%s",lr_eval_string("{UserToken}"));
作者:
fairylly
时间:
2009-1-6 09:39
用下面这个试试:
web_reg_save_param("UserToken",
"LB=CTCGetAuthInfo([email=]'",
"RB='[/email])",
LAST);
作者:
dxf_michael
时间:
2009-1-6 09:42
标题:
回复 3# 的帖子
解决了,谢谢whyleave!
能说一下为啥吗?
作者:
love_yebin
时间:
2009-1-6 12:42
他给你使用参数替代了
作者:
whyleave
时间:
2009-1-6 13:53
参数在使用的时候要加上大括号!
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2