51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 2054|回复: 2
打印 上一主题 下一主题

[求助] 请问如何用web_add_cookie模拟登录状态

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2017-8-21 10:47:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
学习LoadRunner,教程中有一个例子是在phpwind中进行发帖,不想每次都进行登录操作,看网上说可以利用web_add_cookie模拟登录状态,从而避开登录操作,不知道应该怎么做,整体录制的代码如下:
Action()
{

    web_add_cookie("3b937_lastpos=index; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_ol_offset=98; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_ipstate=1502845269; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_cloudClientUid=5253575; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_ck_info=%2F%09; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_lastvisit=196%091502845496%09%2Fphpwind%2Findex.php%3Fmbbs; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_jobpop=1; DOMAIN=172.16.16.80");

    web_add_cookie("3b937_ci=index%091502845496%09%09; DOMAIN=172.16.16.80");

    web_url("index.php",
        "URL=http://172.16.16.80/phpwind/index.php",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t2.inf",
        "Mode=HTML",
        EXTRARES,
      。。
        LAST);

    lr_think_time(19);

    web_submit_data("login.php",
        "Action=http://172.16.16.80/phpwind/login.php?nowtime=1502956686136&verify=17a55952738950d7",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=text/xml",
        "Referer=http://172.16.16.80/phpwind/index.php",
        "Snapshot=t3.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=jumpurl", "Value=http://172.16.16.80/phpwind/index.php", ENDITEM,
        "Name=step", "Value=2", ENDITEM,
        "Name=ajax", "Value=1", ENDITEM,
        "Name=verify", "Value=17a55952738950d7", ENDITEM,
        "Name=pwuser", "Value=suny1", ENDITEM,
        "Name=pwpwd", "Value=123456", ENDITEM,
        "Name=lgt", "Value=0", ENDITEM,
        LAST);

    web_url("index.php_2",
        "URL=http://172.16.16.80/phpwind/index.php",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t4.inf",
        "Mode=HTML",
        EXTRARES,
       ..
        LAST);
    web_url("鏂版墜鏉垮潡",
        "URL=http://172.16.16.80/phpwind/thread.php?fid=3",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://172.16.16.80/phpwind/index.php",
        "Snapshot=t5.inf",
        "Mode=HTML",
        EXTRARES,
..
        LAST);

    web_url("鍙戝笘",
        "URL=http://172.16.16.80/phpwind/post.php?fid=3",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://172.16.16.80/phpwind/thread.php?fid=3",
        "Snapshot=t6.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=js/breeze/core/native.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=images/pwicon/ms_tips.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=images/pwicon/at.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=images/input_down.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=images/post/c_editor/w_edit_but.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/editor/editor.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/core/dom.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/core/event.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/editor/ubb.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/editor/style/full.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/editor/style/B_ico.png", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/app/at.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        "Url=js/breeze/util/localStorage.js?v=1.0.1109", "Referer=http://172.16.16.80/phpwind/post.php?fid=3", ENDITEM,
        LAST);
    web_submit_data("post.php",
        "Action=http://172.16.16.80/phpwind/post.php?fid=3&nowtime=1502956728309&verify=79cc78dac563ce85",
        "Method=POST",
        "EncType=multipart/form-data",
        "TargetFrame=",
        "RecContentType=text/xml",
        "Referer=http://172.16.16.80/phpwind/post.php?fid=3",
        "Snapshot=t7.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=magicname", "Value=", ENDITEM,
        "Name=magicid", "Value=", ENDITEM,
        "Name=verify", "Value=79cc78dac563ce85", ENDITEM,
        "Name=cyid", "Value=0", ENDITEM,
        "Name=ajax", "Value=1", ENDITEM,
        "Name=iscontinue", "Value=0", ENDITEM,
        "Name=atc_title", "Value=this is the first", ENDITEM,
        "Name=atc_content", "Value=first", ENDITEM,
        "Name=usernames", "Value=", ENDITEM,
        "Name=atc_tags", "Value=", ENDITEM,
        "Name=atc_money", "Value=0", ENDITEM,
        "Name=atc_rvrc", "Value=0", ENDITEM,
        "Name=replyreward[replyrewardnum]", "Value=", ENDITEM,
        "Name=replyreward[replyrewardtimes]", "Value=", ENDITEM,
        "Name=replyreward[replyrewardreptimes]", "Value=1", ENDITEM,
        "Name=replyreward[replyrewardchance]", "Value=10", ENDITEM,
        "Name=atc_usesign", "Value=1", ENDITEM,
        "Name=atc_autourl", "Value=1", ENDITEM,
        "Name=atc_convert", "Value=1", ENDITEM,
        "Name=step", "Value=2", ENDITEM,
        "Name=pid", "Value=", ENDITEM,
        "Name=action", "Value=new", ENDITEM,
        "Name=fid", "Value=3", ENDITEM,
        "Name=tid", "Value=0", ENDITEM,
        "Name=article", "Value=0", ENDITEM,
        "Name=special", "Value=0", ENDITEM,
        "Name=_hexie", "Value=ac7f464468d3a8bc", ENDITEM,
        LAST);

    web_add_cookie("_ac_96fd7d51=1; DOMAIN=172.16.16.80");

    web_url("read.php",
        "URL=http://172.16.16.80/phpwind/read.php?tid=1&ds=1",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t8.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=images/pwicon/read_prev.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/wind/reply.png?101129", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/pwicon/add_home.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/online.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/pwicon/add_pro.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/pwicon/add_fri.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/wind/read/yin.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/wind/read/userOper.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/wind/breadEm.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/pwicon/shareAll.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/pre.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/5.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/1.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/2.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/3.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/4.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/6.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/7.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/8.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/9.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/12.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/13.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/10.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/14.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/smile/default/11.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/blank.gif", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/search/pImg.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/post/fp_editor_bg.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=u/images/next.cur", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=u/images/pre.cur", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        "Url=images/search/pImg_close.png", "Referer=http://172.16.16.80/phpwind/read.php?tid=1&ds=1", ENDITEM,
        LAST);

    return 0;
}


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    开心
    2020-1-7 10:41
  • 签到天数: 539 天

    连续签到: 1 天

    [LV.9]测试副司令

    2#
    发表于 2017-8-22 13:52:55 | 只看该作者
    看下这个吧,可能会帮助你理解http://blog.csdn.net/rital/article/details/4195776
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3#
     楼主| 发表于 2017-8-23 08:59:45 | 只看该作者
    Fighting-ing 发表于 2017-8-22 13:52
    看下这个吧,可能会帮助你理解http://blog.csdn.net/rital/article/details/4195776

    恩恩 谢谢
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-11-23 06:34 , Processed in 0.065070 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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