51Testing软件测试论坛

标题: web_reg_find函数为何总返回值为0,高手帮我分析下我错在哪了 [打印本页]

作者: ljfzqq    时间: 2012-3-5 14:15
标题: web_reg_find函数为何总返回值为0,高手帮我分析下我错在哪了
代码如下:
Action()
{
web_reg_find("Search=Body",
                         "SaveCount=a_count",
                         "Text=星期一",LAST);


        web_submit_data("login!login.action",
                "Action=http://172.17.192.1:8080/test/login!login.action",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://172.17.192.1:8080/test/login1024.jsp",
                "Snapshot=t3.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=screenSize", "Value=1024", ENDITEM,
                "Name=loginId", "Value=liujf", ENDITEM,
                "Name=password", "Value=liujf", ENDITEM,
                "Name=imageField.x", "Value=35", ENDITEM,
                "Name=imageField.y", "Value=0", ENDITEM,
                EXTRARES,
                "Url=images/dtree/base.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/plus.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/joinbottom.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/line.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/folder.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/join.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/page.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/empty.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/folderopen.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/plusbottom.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/dtree/minus.gif", "Referer=http://172.17.192.1:8080/test/frame/left.jsp", ENDITEM,
                "Url=images/table/tblbg.gif", "Referer=http://172.17.192.1:8080/test/jsp/Submit_record/Submit_recordAction!querySubmit_record_first.action", ENDITEM,
                "Url=components/calendar/datetime.js", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/plugins.js", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/datetime.css", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/arrowl.gif", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/arrowr.gif", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/plus.gif", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/minus.gif", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/bb.JPG", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                "Url=components/calendar/agenda.js?1330927440484", "Referer=http://172.17.192.1:8080/test/components/calendar/ipopeng.htm", ENDITEM,
                LAST);
if(atoi(lr_eval_string("{a_count}"))>0)
        lr_output_message("found");
else
lr_error_message("nofound");
        return 0;
}
这是一个登录系统,登录后页面会有显示文本“星期一”,但是为何我跑完脚本后,返回值是NOFOUND,count计数为0啊?
还有我选中UTF-8和没选中UTF-8都是一个样啊
作者: 云层    时间: 2012-3-6 11:36
今天是星期二了
作者: allenchen1986    时间: 2012-3-7 11:51
试试用英文做检查点。建议不要用汉字做检查
作者: TesterChen    时间: 2012-3-8 10:17
回复 1# ljfzqq


    从以下几个方面去调试:
    1、通过树视图看你的返回里有没有你要查找的关键字,且看他的位置在哪里
    2、查找一个肯定存在的字符串,看能不能找到,结果是否正确
    3、web_reg_find("Search=Body",
                         "SaveCount=a_count",
                         "Text=星期一",LAST);
     尝试修改为 Search=ALL
     4、检查最后的判断语句是否有错误,可以在3中的web_reg_find函数中添加 "Fail=NotFound"
作者: mumu.ai    时间: 2012-3-8 12:32
直接在tree模式下,自动添加,再试试
作者: ww7446844    时间: 2012-3-8 13:15
2楼厉害
作者: 蓝色水滴    时间: 2012-3-14 15:57
我也碰到这个问题了。
作者: asa87053236    时间: 2012-5-23 15:53
回复 7# 蓝色水滴
你咋解决的啊?




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2