查看完整版本: 关于LoadRunner手动关联的问题?为什么无法关联

sandsor 2008-3-9 20:56

关于LoadRunner手动关联的问题?为什么无法关联

[size=4]我今天在做OA  loadrunner测试的时候,发现这段代码无法做手动关联,参考了很多资料也束手无策:( ,[/size]
[size=4]原代码如下: [/size]
[size=4][/size]
[size=4]       web_custom_request("Weather.getWeather.dwr",
                "URL=http://192.168.1.100:9090/dwr/call/plaincall/Weather.getWeather.dwr",
                "Method=POST",
                "Resource=1",
                "RecContentType=text/plain",
                "Referer=http://192.168.1.100:9090/head.jsp",
                "Snapshot=t62.inf",
                "EncType=text/plain",
                "Body=callCount=1\npage=/head.jsp\nhttpSessionId=[color=red]FA2D2A310C746A68A01FD3E49BE3BCA3[/color]\nscriptSessionId=[color=red]6BD34CF9057629A5E83064C03FEDEA93952[/color]\nc0-scriptName=Weather\nc0-methodName=getWeather\nc0-id=0\nc0-param0=string:%E7%8F%A0%E6%B5%B7\nbatchId=0\n",
                LAST);[/size]
[size=4][/size]
[size=4]在录制两份脚本比较后,初步定义需要关联的部分(红色)[/size]
[size=4]//httpsession1=[color=#ff0000]FA2D2A310C746A68A01FD3E49BE3BCA3[/color][/size]
[size=4][color=gray]//[color=#7b7d72]scriptSession1=[/color][color=#ff0000]6BD34CF9057629A5E83064C03FEDEA93952[/color][/color][/size]
[size=4][color=#ff0000][/color][/size]
[size=4]web_reg_save_param("httpSession1",[/size]
[size=4]"LB/IC=httpSessionId=",[/size]
[size=4]"RB/IC=\nscriptSessionId=",[/size]
[size=4]"ORD=1",[/size]
[size=4]"search=Body",[/size]
[size=4]LAST);[/size]
[size=4][/size]
[size=4][size=4]web_reg_save_param("scriptSession1",[/size]
[size=4]"LB/IC=scriptSessionId=",[/size][/size]
[size=4][size=4]"RB/IC=\n",[/size]
[size=4]"ORD=1",[/size]
[size=4]"search=Body",[/size]
[size=4]LAST);[/size]

[/size][size=4]web_custom_request("Weather.getWeather.dwr",
"URL=http://192.168.1.100:9090/dwr/call/plaincall/Weather.getWeather.dwr",
        ......[/size]
[size=4]"Body=callCount=1\npage=/head.jsp[color=blue]\[/color]nhttpSessionId=[color=red]{httpsession1}[/color][color=blue]\[/color]nscriptSessionId=[color=red]{scriptSession1}[/color][color=blue]\[/color]nc0-scriptName=Weather[color=blue]\[/color]nc0-methodName=getWeather\nc0-id=0\nc0-param0=string:%E7%8F%A0%E6%B5%B7\nbatchId=0\n",
LAST);
[/size][size=4]然后把写死的(hard-coded)的资料参数化,在执行的时候检查关联却没有反应,[/size]
[size=4]是什么原因? 是特殊字符的原因(\)?还是我哪一步没做好,请指教。。[/size]

[[i] 本帖最后由 sandsor 于 2008-3-9 21:12 编辑 [/i]]

Zee 2008-3-9 22:17

把你得到的值打印出来看看。
把\n改成\\n呢?

liangjz 2008-3-10 08:28

楼主按zee的,用lr_error_message("%s",lr_eval_string("{ varname}")) 打印

sandsor 2008-3-10 13:17

[size=4]按zee的说法,对"\"加上 转义,[/size]
[size=4]如liangjz 所说加上 [/size][size=3]lr_error_message()检查语句[/size]
[size=3][/size]
[size=4]//-------------------------
//http1=C05D000944884C36EA5BF229C097CD9E
//script1=943CCB2195F6593F3717E2ADB76366F5231[/size]

[size=4] web_set_max_html_param_len("1024");
web_reg_save_param("http1",
  "LB/IC=httpSessionId=",
  "RB/IC=[color=blue]\\[/color]nscriptSessionId=",
  "Ord=all",
  "Search=Body",
  "RelFrameId=1",
  LAST);[/size]
[size=4][/size]
[size=4] web_reg_save_param("script1",
  "LB/IC=scriptSessionId=",
  "RB/IC=[color=blue]\\[/color]n",
  "Ord=all",
  "Search=Body",
  "RelFrameId=1",
  LAST);[/size]
[size=4]
[/size]
[size=4] web_custom_request("User.login.dwr",
  "URL=http://www.jingmaoju.com:9090/dwr/call/plaincall/User.login.dwr",
  "Method=POST",
  "Resource=1",
  "RecContentType=text/plain",
  "Referer=http://www.jingmaoju.com:9090/",
  "Snapshot=t18.inf",
  "EncType=text/plain",
  "Body=callCount=1\npage=/\nhttpSessionId=[color=red]{http1}[/color]\nscriptSessionId=[color=red]{script1}[/color]\nc0-scriptName=User\nc0-methodName=login\nc0-id=0\nc0-param0=string:lq\nc0-param1=string:123\nc0-param2=string:\nc0-param3=string:\nbatchId=0\n",
  LAST);
//output the value
lr_error_message("http1 value is %s",lr_eval_string("{http1}"));
lr_error_message("script1 value is %s",lr_eval_string("{script1}"));
[/size]
[size=4]=====================================
[/size][size=4]执行后的报告如下:(录制方式URL_based script)[/size]
[size=4]---------------------------------[/size]
[size=4][size=3]Action.c(175):     if (window.dwr) dwr.engine._remoteHandleBatchException({ name:'java.lang.SecurityException
[color=red][/color][/size][/size]
[size=4][size=3][color=red]Action.c(175):     ', message:'Session Error' });\r\n[/color]
[/size][/size]
[size=4][size=3]Action.c(175):     else if (window.parent.dwr) window.parent.dwr.engine._remoteHandleBatchException({ name:'j
[/size][size=3][color=red][/color][/size][/size]
[size=4][size=3][color=red]Action.c(175):     ava.lang.SecurityException', message:'Session Error' });\r\n
[/color][/size][/size]
[size=4][size=3]Action.c(175): t=11939ms: Request done "http://www.jingmaoju.com:9090/dwr/call/plaincall/User.login.dwr"   [MsgId: MMSG-26000]
[/size][size=3][color=red][/color][/size][/size]
[size=4][size=3][color=red]Action.c(175): Error -26377: No match found for the requested parameter "http1". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 1024 bytes, use web_set_max_html_param_len to increase the parameter size   [MsgId: MERR-26377]
[/color][color=blue][/color][/size][/size]
[size=4][size=3][color=blue]Action.c(175): Notify: Saving Parameter "http1_count = 0"[/color]
[/size][size=3][color=red][/color][/size][/size]
[size=4][size=3][color=red]Action.c(175): Error -26377: No match found for the requested parameter "script1". Check whether the requested boundaries exist in the response data. Also, if the data you want to save exceeds 1024 bytes, use web_set_max_html_param_len to increase the parameter size   [MsgId: MERR-26377]
[/color][color=blue][/color][/size][/size]
[size=4][size=3][color=blue]Action.c(175): Notify: Saving Parameter "script1_count = 0"[/color]
[/size][size=3][color=red]Action.c(175): web_custom_request("User.login.dwr") highest severity level was "ERROR", 284 body bytes, 252 header bytes   [MsgId: MMSG-26388]
[/color]Ending action Action.[/size][/size]
[size=4]--------------------------[/size]
[size=4]错误报告是什么意思,我用URL_base script 方式录制(OA是采用AJAX技术)[/size][size=4]
[/size]

云层 2008-3-10 16:12

出错说明你没关联到数据所以script1_count = 0

sandsor 2008-3-10 17:14

会不会是不支持 Ajax 的缘故呢

zibeike 2008-3-10 18:47

你可以把左右边界避开\n, 然后使用偏移量取需要的数据长度,当然前提是这些数据长度是固定的.

sandsor 2008-3-10 21:36

[quote]原帖由 [i]zibeike[/i] 于 2008-3-10 18:47 发表 [url=http://bbs.51testing.com/redirect.php?goto=findpost&pid=899083&ptid=107990][img]http://bbs.51testing.com/images/common/back.gif[/img][/url]
你可以把左右边界避开\n, 然后使用偏移量取需要的数据长度,当然前提是这些数据长度是固定的. [/quote]

哦,我试试。。
{http1}  和 {script1}  的后面紧跟着就是 \ 符号

网上有说 LR 8.1+FP4  的 LR9.0 才支持 AJAX 的回放, 真是这样么,
我用的才是LR 8.0 啊。。。。

[[i] 本帖最后由 sandsor 于 2008-3-10 22:03 编辑 [/i]]

andy 2008-3-26 09:52

这个问题最终怎么解决的?

toly_sun 2008-3-26 10:12

做关联的地方错了!

web_custom_request已经在提交请求了, httpSessionId={http1} scriptSessionId={script1}
这里的{http1}和{script1}应该在提交之前就取得,而且也不应该从client request的data里面来确定边界,边界是从server response里面确定的 

云层 2008-3-26 10:28

关联函数的位置有问题,请把这个关联往前放

gaopu202 2008-6-18 22:16

关联函数的位置和取的左右边界值不正确

关联函数的位置一般是放在submit_data的前面(在树形模式下右键插入,选择在之前插入),左右边界值可以从server返回的日志中得到(在runntime setting中可以选择Data returned by server,把data日志打开就可以看到了,日志文件名为:mdrv.log),注意是response中的,不是在UG中看到的request中的。
这个问题还比较好办,我碰到的问题是:在mdrv.log日志中看到的httpSessionId=dwr.getJSessionId();JSessionId是在登陆的时候在cookie中产生的。难道还要做一次关联??我的web_custome_request函数发给服务器端没有反应(在录制好的脚本中),我把web_custome_request拷贝出来单独放到一个action中就可以把命令下发下去,服务器有反应(通过日志查看到的)。
郁闷!!!请高手出马!!
页: [1]
查看完整版本: 关于LoadRunner手动关联的问题?为什么无法关联