分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 网页技术

Loadrunder脚本篇——web_custom_request做接口测试

发布时间:2023-09-06 01:40责任编辑:林大明关键词:暂无标签

一、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);

 

 

运行结果:



 

 

说明: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);

 

运行结果:

 



 

三、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;

 

}

Loadrunder脚本篇——web_custom_request做接口测试

原文地址:https://www.cnblogs.com/langhuagungun/p/8391485.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved