loadrunner 添加token关联

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了loadrunner 添加token关联相关的知识,希望对你有一定的参考价值。

1、token是服务器返回的一个值,

用于验证身份。

因此需要在response body中查找第一次出现token的地方。

2、token是登录时候返回的,因此需要在登录的请求那里找。

3、切换到树图,找到响应的登录操作

技术分享

3、添加关联之后,脚本中会增加一个语句,它出现在登录之前。

/Correlation comment - Do not change!Original value=48d5b44a89864d17b86509a201cc942c Name =CorrelationParameter_1
    web_reg_save_param_ex(
        "ParamName=CorrelationParameter_1",
        "LB=:\\"",
        "RB=\\",",
        SEARCH_FILTERS,
        "Scope=Body",
        "RequestUrl=*/authentication*",
        LAST);
    web_submit_data("authentication",
        "Action=http://www.moojnn.com/mojingcsp/authentication",
        "Method=POST",
        "TargetFrame=",
        "RecContentType=application/json",
        "Referer=http://www.moojnn.com/user/login.html",
        "Snapshot=t3.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=username", "Value={userName}", ENDITEM,
        "Name=password", "Value=e10adc3949ba59abbe56e057f20f883e", ENDITEM,
        EXTRARES,
        "URL=http://pro.moojnn.com/lib/leaflet/leaflet.css?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/css/icon/style.css?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/css/common.css?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/js/mjchart/theme/mjvi.css?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/js/config.js", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/js/functions.js?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/js/mjchart/mjvi.min.js?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/js/common.js?_d=1467120445822", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=../static/js/csp.js?_=1467473737411", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        LAST);

    web_url("popup-help.html_2",
        "URL=http://www.moojnn.com/user/popup-help.html?from=http%3A%2F%2Fpro.moojnn.com%2Fprojects.html%23%2F%3FMoJing-Token%3D{CorrelationParameter_1}",
        "TargetFrame=",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://pro.moojnn.com/projects.html",
        "Snapshot=t4.inf",
        "Mode=HTML",
        EXTRARES,
        "URL=http://hm.baidu.com/hm.js?177ebef2f9a9244c738b903eef680a83", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://z6.cnzz.com/stat.htm?id=1253524178&r=http%3A%2F%2Fwww.moojnn.com%2Fuser%2Flogin.html&lg=zh-cn&ntime=1467467462&cnzz_eid=1418985023-1467467462-http%3A%2F%2Fwww.moojnn.com%2F&showp=1366x768&p=http%3A%2F%2Fpro.moojnn.com%2Fprojects.html%23%2F%3FMoJing-Token%3D{CorrelationParameter_1}&t=&h=1&rnd=1141052232", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://pro.moojnn.com/mojing-server/user/login?MoJing-Token={CorrelationParameter_1}", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        "URL=http://hm.baidu.com/hm.gif?cc=0&ck=1&cl=24-bit&ds=1366x768&et=0&fl=22.0&ja=0&ln=zh-CN&lo=0&lt=1467473654&nv=0&rnd=1523982449&si=177ebef2f9a9244c738b903eef680a83&st=4&su=http%3A%2F%2Fwww.moojnn.com%2Fuser%2Flogin.html&v=1.1.26&lv=3", "Referer=http://pro.moojnn.com/projects.html", ENDITEM,
        LAST);

 

以上是关于loadrunner 添加token关联的主要内容,如果未能解决你的问题,请参考以下文章

LoadRunner11 实现token的解析与认证

loadrunner11关联

Loadrunner关联取参及设置检查点

EF添加关联的提示问题:映射从第 260 行开始的片段时有问题:

性能测试学习第三天-----loadrunner接口测试&中文乱码处理

loadrunner录制一个添加数据的脚本,但是在脚本回放时却不能添加数据,为啥呢?急啊,各位大侠帮帮忙!