在学习web_reg_find函数时,发现帮助文档的example 1中是使用的web_submit_form函数提交的表单
而我录制脚本时是使用的web_submit_data函数,并在该函数前添加脚本:
web_reg_find("text=welcome",
LAST);
总是出错,日志为:
Action.c(22): Error -26366: "Text=welcome" not found for web_reg_find [MsgId: MERR-26366]
Action.c(22): web_submit_data("login.pl") highest severity level was "ERROR", 795 body bytes, 225 header bytes [MsgId: MMSG-26388]
经过分析是发现login.pl页面错误了,去掉web_reg_find函数却又登陆成功了,很奇怪
后来发现是由于没有建立关联导致的,可我有没有在Web Tours网站中开启“Set LOGIN form's action tag to an error page”选项
通过添加关联函数,再次使用web_reg_find函数后,发现都成功了,呵呵,这也算是一个小小的经验吧。
脚本如下:
Action()
{
web_reg_save_param("usersession",
"LB/IC=name=userSession value=",
"RB/IC=>",
"ORD=1",
LAST);
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST);
web_reg_find("text=welcome",
LAST);
web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/WebTours/login.pl",
"Method=POST",
"TargetFrame=body",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
"Snapshot=t4.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value={usersession}", ENDITEM,
"Name=username", "Value=alex", ENDITEM,
"Name=password", "Value=30761234", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=54", ENDITEM,
"Name=login.y", "Value=14", ENDITEM,
LAST);
return 0;
}