LoadRunner保存服务器返回字符串问题求助,项目紧急,在线等回复!
编了一段脚本代码,想要将服务器的返回中一个字符串保存下来,但是不知道为什么,好像一直无法保存,运行也没报错,字符串变量一直是空的。Action()
{
char UserToken;
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('@@Q31EeaLZE@nq0QDPvlx6ZddBSQe5yr');
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 -->
<divstyle="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
Run-Time Settings file: "D:\Program Files\Mercury\LoadRunner\scripts\http\\default.cfg"
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(5): Registering web_reg_save_param was successful
Action.c(9): web_url("index.jsp") was successful, 1307 body bytes, 214 header bytes
Action.c(18): UserToken=
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated. 等待高手的出现! lr_output_message("UserToken=%s",lr_eval_string(UserToken));
改成 lr_output_message("UserToken=%s",lr_eval_string("{UserToken}")); 用下面这个试试:
web_reg_save_param("UserToken",
"LB=CTCGetAuthInfo('",
"RB=')",
LAST);
回复 3# 的帖子
解决了,谢谢whyleave!能说一下为啥吗? :L他给你使用参数替代了 :L 参数在使用的时候要加上大括号!
页:
[1]