51Testing软件测试论坛
标题:
取得关联的值问题
[打印本页]
作者:
kuangquanshui
时间:
2011-4-12 11:48
标题:
取得关联的值问题
使用关联函数后取得不到里面的值。写到文件中的内容为空 。是不是哪里写错了
脚本如下:
Action()
{
int flen; //定义一个整型变量保存获得文件的大小
int length;
long filedes; //保存文件句柄
char file[256]="\0"; //保存文件路径及文件名
char buffer[700]="";
web_set_max_html_param_len("9999999");//设置页面接收最大的字节数,该设置应大于下载文件的大小
web_reg_save_param("filecontent",
"LB=<body>",
"RB=</body>",
"Search=ALL",
LAST);
lr_output_message(lr_eval_string("{filecontent}"));
flen = 650;
web_url("
www.baidu.com
",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=/img/i2.png", ENDITEM,
"Url=/img/arr.gif", ENDITEM,
"Url=/js/bdsug.js?v=1.0.3.0", ENDITEM,
"Url=/favicon.ico", "Referer=", ENDITEM,
LAST);
lr_save_string(lr_eval_string("{filecontent}"),"buffer");
lr_output_message("%s",buffer);
lr_output_message("%d",flen);
if(flen > 0)
{
if((filedes = fopen("d:\\test.txt", "wb")) == NULL)
{
lr_output_message("Open File Failed!", lr_eval_string("{filecontent}"));
return -1;
}
fwrite(buffer,flen,10,filedes );
fclose( filedes );
}
return 0;
}
日志结果如下:
Starting action Action.
Action.c(10): web_set_max_html_param_len was successful [MsgId: MMSG-26392]
Action.c(11): Registering web_reg_save_param was successful [MsgId: MMSG-26390]
Action.c(16): {filecontent}
Action.c(20): Found resource "
http://www.baidu.com/img/baidu_sylogo1.gif
" in HTML "
http://www.baidu.com/
" [MsgId: MMSG-26659]
Action.c(20): Found resource "
http://gimg.baidu.com/img/gs.gif
" in HTML "
http://www.baidu.com/
" [MsgId: MMSG-26659]
Action.c(20): Downloading resource "
http://www.baidu.com/img/i2.png
" (specified by argument number 9) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "
http://www.baidu.com/img/arr.gif
" (specified by argument number 11) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "
http://www.baidu.com/js/bdsug.js?v=1.0.3.0
" (specified by argument number 13) [MsgId: MMSG-26577]
Action.c(20): Downloading resource "
http://www.baidu.com/favicon.ico
" (specified by argument number 15) [MsgId: MMSG-26577]
Action.c(20): web_url("
www.baidu.com
") was successful, 9439 body bytes, 2232 header bytes [MsgId: MMSG-26386]
Action.c(34):
Action.c(35): 650
Ending action Action.
作者:
云层
时间:
2011-4-12 12:59
把关联函数的search=all改成1就会有结果了,整理错误比较多(概念问题)
作者:
kuangquanshui
时间:
2011-4-12 13:16
回复
2#
云层
这里的搜索位置可以设置只有all 、body、 header 、No resources
刚才设置了一下报错了
Action.c(8): web_set_max_html_param_len was successful [MsgId: MMSG-26392]
Action.c(9): Error -27289: Unrecognized value ("1") for the "Search" argument (number 4) [MsgId: MERR-27289]
Action.c(9): Registering web_reg_save_param highest severity level was "ERROR" [MsgId: MMSG-26389]
Ending action Action.
可能是我理解错了 能详细说下吗
作者:
kuangquanshui
时间:
2011-4-14 10:14
自己结贴
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2