博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Loadrunner 脚本开发-利用web_custom_request函数进行接口测试
阅读量:5074 次
发布时间:2019-06-12

本文共 2971 字,大约阅读时间需要 9 分钟。

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

by:授客 QQ1033553122

 

一、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-B204","

        ""businessScope":"3","

        ""businessLicenseCode":"140100200567176","                                       

        ""businessLicenseUrl":"2016/01/04/fcd1bde5-f64f-4aa6-82c9-82b65cd

7ccfd.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-47e47ab95d0

8.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 || //strcmp(""21"",lr_eval_string("{result}"))==0)   

 

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;

 

}

 

转载于:https://www.cnblogs.com/shouke/p/10157794.html

你可能感兴趣的文章
20150929,所学整理
查看>>
oracle PL/SQL
查看>>
MapReduce --- shuffle阶段图解
查看>>
Mysql常用命令操作之增删改查
查看>>
erlang lists模块函数使用大全
查看>>
加密算法-RSA
查看>>
SharePoint 2010 Ribbon with wrong style in Chrome and Safari
查看>>
Archlinux 踩坑实录
查看>>
路由器 NorFlash与NandFlash区别
查看>>
iptables/Netfilter 学习
查看>>
正则表达式之Regex.Matches()用法
查看>>
车载行业认证资质
查看>>
[leetcode] 16. 最接近的三数之和
查看>>
设计模式概要
查看>>
spring接收参数
查看>>
IIS状态监测(如果状态错误则重启IIS)
查看>>
从Discuz!NT项目文件结构看如何给系统框架分层和类库分文件夹
查看>>
22、Java并发性和多线程-Java中的读/写锁
查看>>
HDOJ 1250 Hat's Fibonacci 简单解题报告
查看>>
mvc5 + ef6 + autofac搭建项目(repository+uow)(二)
查看>>