chenbixiu 发表于 2010-8-16 11:01:01

脚本优化后出现问题,解决不了,求助!

设置检查点并回放以下脚本,发现用正确的登录名和用错误的登录名登录系统后,都显示登录成功,不知道是什么原因造成的,是脚本有问题吗?我找了很久没找出来,麻烦各位高手帮忙一下,谢谢!

submit_login()
{        lr_think_time(71);
        lr_rendezvous("login_rendezvous");

        web_submit_data("logon.do;jsessionid=13A4DD4CAD9E636BC9F6FA2513B38891",
                "Action=http://192.168.2.95:9000/kb/logon.do;jsessionid={CSRule_1_UID2}",
                "Method=POST",
                "RecContentType=text/html",
                "Referer=http://192.168.2.95:9000/kb/",
                "Snapshot=t2.inf",
                "Mode=HTML",
                ITEMDATA,
                "Name=state", "Value=logon", ENDITEM,
                "Name=userName", "Value={username}", ENDITEM,
                "Name=password", "Value={password}", ENDITEM,
                LAST);
       

        lr_start_transaction("confirm page");


        //web_add_cookie("treeConfig=0; DOMAIN=192.168.2.95");

    /*web_reg_find("Fail=NotFound",
                "Search=Body",
                "SaveCount=num",
                "Text=首 页",
                LAST);

web_link("首页",
                "Text=首页",
                "Snapshot=t6.inf",
                LAST);*/


   
        web_reg_find("Text=当前用户:",
                "Search=body",
                LAST);
        web_url("mainFrame.jsp",
                "URL=http://192.168.2.95:9000/kb/mainFrame.jsp",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Snapshot=t3.inf",
                "Mode=HTML",
                EXTRARES,
                "URL=include/images/top_1.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/down_3.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/button_head_down.gif", "Referer=http://192.168.2.95:9000/kb/title.jsp", ENDITEM,
                "URL=include/images/top_2.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/down_1.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/down_2.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/down.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/right_tool.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/top.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=include/images/left_tool.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=common/treeselect/css/xtree2.css", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=common/treeselect/images/tree2/start_on.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=common/treeselect/images/tree2/L.png", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=common/treeselect/images/tree2/loading.gif", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=common/treeselect/images/tree/I.png", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                LAST);

        web_url("treexml.jspx",
                "URL=http://192.168.2.95:9000/kb/common/treeselect/treexml.jspx?type=2&nodeID=0&dataType=1&allKe=0&archiveKe=0&hideKe=0&curDate=Tue%20Aug%203%2008:36:38%20UTC+0800%202010",
                "Resource=0",
                "RecContentType=text/xml",
                "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1",
                "Snapshot=t4.inf",
                "Mode=HTML",
                EXTRARES,
                "URL=images/tree2/folder.png", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=images/tree2/Tplus.png", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                "URL=images/tree2/Lplus.png", "Referer=http://192.168.2.95:9000/kb/ke/keTree.do?state=list&dataType=2&showType=1", ENDITEM,
                LAST);



        lr_end_transaction("confirm page", LR_AUTO);

    lr_log_message("用户名为:%s", lr_eval_string("{username}"));
    lr_log_message("密码:%s", lr_eval_string("{password}"));

        if(strcmp(lr_eval_string("{num}"),"0")==0) {
                lr_log_message("登录失败");
                }
                        else {
                                lr_log_message("登录成功");
                                }
       
        return 0;
}

xueying1123 发表于 2010-8-16 11:51:04

/*web_reg_find("Fail=NotFound",
                "Search=Body",
                "SaveCount=num",
                "Text=首 页",
                LAST);

web_link("首页",
                "Text=首页",
                "Snapshot=t6.inf",
                LAST);*/
----------------------
这段被你注释了,num参数取不到值吧;
还有你文本检查的关键字不具代表性吧,是不是登录成功失败这些关键字都会出现在页面中

云层 发表于 2010-8-16 12:57:38

where is your num?

chenbixiu 发表于 2010-8-16 15:01:00

改换版本,查出是检查点找不到,但是具体原因还是一头雾水

我改用9.0的版本运行,它会提示检查点找不到,可是这个检查点明明在页面和源程序中都可以找到,请高手们指教。
Running Vuser...
Starting iteration 1.
Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.This may produce unpredictable results with multiple iterations       
Starting action Action.
Ending action Action.
Starting action submit_login.
submit_login.c(7): Rendezvous login_rendezvous
submit_login.c(9): web_submit_data("logon.do;jsessionid=13A4DD4CAD9E636BC9F6FA2513B38891") was successful, 1530 body bytes, 338 header bytes       
submit_login.c(23): Notify: Transaction "confirm page" started.
submit_login.c(28): Registering web_reg_find was successful       
submit_login.c(34): Error -27995: Requested link ("Text=首页") not found       
submit_login.c(34): Warning -26379: Pending web_reg_save_param/reg_find/create_html_param request(s) are deleted and will be handled as "not found"       
submit_login.c(34): Error -26366: "Text=首 页" not found for web_reg_find       
submit_login.c(34): Error -26374: The above "not found" error(s) may be explained by header and body byte counts being 0 and 0, respectively.        submit_login.c(34): web_link("首页") highest severity level was "ERROR", 0 body bytes, 0 header bytes       
submit_login.c(34): Notify: Transaction "confirm page" ended with "Fail" status (Duration: 0.1292).
Ending action submit_login.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.

[ 本帖最后由 chenbixiu 于 2010-8-16 15:03 编辑 ]

chenbixiu 发表于 2010-8-16 15:04:18

回复 2# 的帖子

呵呵,这是我后来注释掉的!

chenbixiu 发表于 2010-8-16 16:35:21

谢谢大家,问题解决了!是cookie问题!因为IE浏览器会在缓存中保留上一次的记录,导致后面的用户也跟前面一样,我后来把脚本中的COOKIE注释掉,问题就解决了。

[ 本帖最后由 chenbixiu 于 2010-8-20 11:31 编辑 ]

ganlan 发表于 2010-8-16 19:01:56

是怎么解决的?也不分享下。
页: [1]
查看完整版本: 脚本优化后出现问题,解决不了,求助!