zoukankan      html  css  js  c++  java
  • Loadrunder脚本篇——web_custom_request做接口测试

    一、POST + JSON格式参数

    例:

     

    web_custom_request("create",

     

    "URL=http://xxx.xxx.x.xx:1600/ditui/agentshop",

     

    "Method=POST",

     

    "Resource=0",

     

    "RecContentType=application/json",

     

    "Referer=",

     

    "Mode=HTML",

     

    "EncType=application/json;charset=UTF-8",

     

    "Body={"agentId":31,"


    ""contactName":"test","


    ""contactPhone":"18259001421","

     

    ""fullName":"赖大家家里蹲分公司1","

     

    ""shortName":"Le3JxD","

     

    ""vipEmail":"1033553122@qq.com","

     

    ""shopType":"1","

     

    ""address":"广东省深圳市宝安区华侨新村29-B座204","

     

    ""businessScope":"3","

     

    ""businessLicenseCode":"140100200567176","

     

    ""businessLicenseUrl":"2016/01/04/fcd1bde5-f64f-4aa6-82c9-82b65cd7ccfd.jpg","

     

    ""province":"620000","

     

    ""city":"620200","

     

    ""area":"620201","

     

    ""headAddress":"广东省深圳市宝安区","

     

    ""legalName":"袁国新","

     

    ""idCard":"451202198403264276","

     

    ""idCardStartDate":"2010-10-06","

     

    ""idCardEndDate":"2020-10-06","

     

    ""idCardFrontUrl":"2016/01/06/d342b28d-c62d-416e-b947-47e47ab95d08.jpg","

     

    ""idCardBackUrl":"2016/01/06/f03e967a-168c-4ba6-ba99-04a3c6790bf6.jpg","

     

    ""phoneNumber":"18259001421"}",

     

    LAST);

     

     

    运行结果:

    Loadrunner <wbr>脚本开发-利用web_custom_request函数进行接口测试

     

     

    说明:Body写法

    1)参数都写在一行

    "Body={"arg1":int_value1,"arg2":"str_value2",…, "argN":"valueN"}",

     

    2)参数不都在同一行

    "Body={"arg1":value1,"

            ""arg2":"str_value2","

            ""arg3":"str_value3","

             ……

            ""argN":"valueN"}",

     

     

    二、POST + 非JSON格式参数

    例:

    web_custom_request("login",

            "URL=http://127.0.0.1:1080/WebTours/login.pl",

            "Method=POST",

            "Resource=0",

            "RecContentType=",

            "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

            "Mode=HTML",

            "EncType=application/x-www-form-urlencoded",          

            "Body=userSession=117812.897691373zAzAAAApQcfDzDzApAAfff&username=jo

    jo&password=bean&login.x=0&login.y=0&JSFormSubmit=off",

            LAST);

     

    运行结果:

     

    Loadrunner <wbr>脚本开发-利用web_custom_request函数进行接口测试

     

    三、GET

    例:

    web_custom_request("view_active_page",       

            "URL=http://xx.xxxxx.xxxx.cn/index.php?xx=/xxxx/Lucky/Christport/sav

    e_user_info/id/726/token/84222366b2592714538e50dc69398ad7/open_id/ous64uNjaBudzU00000751vYH9k/nickname/test_user/headimgurl/testurl",

            "Method=GET",

            "Resource=0",

            "RecContentType=Application/json",

            "Referer=",

            "Mode=HTML",

            "EncType=application/x-www-form-urlencoded;charset=UTF-8",

            "Body=",

            LAST);

     

    一个完整的例子

    Join_active()

    {

        web_reg_save_param("result",

            "LB=result":",

            "RB=,"",

            "NotFound=ERROR",

            "Search=All",

            LAST);

     

        lr_rendezvous("join_active");

     

        //参与抽奖

        lr_start_transaction("join_active");

     

     

        web_custom_request("choujiang",

            "URL=http://xx.xxx.xxxx/index.php?s=/addon/Lucky/Christport/lucky/id/726/open_id/{open_id}/token/84222366b2592714538e50dc69398ad7",

            "Method=GET",

            "Resource=0",

            "RecContentType=Application/json",

            "Referer=",

            "Mode=HTML",

            "EncType=application/x-www-form-urlencoded;charset=UTF-8",

            "Body=",

            LAST);

     

    if(strcmp("102",lr_eval_string("{result}"))==0 || strcmp("103",lr_eval_string("{result}"))==0)

        {

     

                lr_end_transaction("join_active", LR_PASS);

     

        }else{

     

                lr_end_transaction("join_active", LR_FAIL);

     

        }

        return 0;

     

    }

  • 相关阅读:
    curl命令学习笔记
    IOS安全测试思维导图
    Hello World
    Hive SQL使用和数据加载的一点总结
    采用最低松弛度优先调度的实时系统调度程序
    MongoDB Map Reduce速度提升20倍的优化宝典
    释放时间不同可中断平行机问题在线算法
    RPC框架系列——Avro
    Solr 3.6.2索引MySQL数据库配置过程
    IKAnalyzer 独立使用 配置扩展词库
  • 原文地址:https://www.cnblogs.com/langhuagungun/p/8391485.html
Copyright © 2011-2022 走看看