51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2459|回复: 6
打印 上一主题 下一主题

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

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 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;
}
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 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参数取不到值吧;
还有你文本检查的关键字不具代表性吧,是不是登录成功失败这些关键字都会出现在页面中
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2010-8-16 12:57:38 | 只看该作者
where is your num?
回复 支持 反对

使用道具 举报

该用户从未签到

4#
 楼主| 发表于 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          [MsgId: MWAR-27077]
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          [MsgId: MMSG-26386]
submit_login.c(23): Notify: Transaction "confirm page" started.
submit_login.c(28): Registering web_reg_find was successful          [MsgId: MMSG-26390]
submit_login.c(34): Error -27995: Requested link ("Text=首页") not found          [MsgId: MERR-27995]
submit_login.c(34): Warning -26379: Pending web_reg_save_param/reg_find/create_html_param[_ex] request(s) are deleted and will be handled as "not found"          [MsgId: MWAR-26379]
submit_login.c(34): Error -26366: "Text=首 页" not found for web_reg_find          [MsgId: MERR-26366]
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.          [MsgId: MERR-26374]
submit_login.c(34): web_link("首页") highest severity level was "ERROR", 0 body bytes, 0 header bytes          [MsgId: MMSG-26388]
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 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

5#
 楼主| 发表于 2010-8-16 15:04:18 | 只看该作者

回复 2# 的帖子

呵呵,这是我后来注释掉的!
回复 支持 反对

使用道具 举报

该用户从未签到

6#
 楼主| 发表于 2010-8-16 16:35:21 | 只看该作者
谢谢大家,问题解决了!是cookie问题!因为IE浏览器会在缓存中保留上一次的记录,导致后面的用户也跟前面一样,我后来把脚本中的COOKIE注释掉,问题就解决了。

[ 本帖最后由 chenbixiu 于 2010-8-20 11:31 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2010-8-16 19:01:56 | 只看该作者
是怎么解决的?也不分享下。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-14 14:34 , Processed in 0.072192 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表