再识web_custom_request之post(Jmeter VS Loadrunner)
2014-11-20 16:04
148 查看
工具选择篇,笔者使用了jmeter工具和LR对接口进行压测,并使用WireShark进行抓包分析。
一、Jmeter
jmeter不涉及到断言之类的操作,只聊http请求。
1、下图为http请求,BodyData中说明发送数据的格式为json
2、在查看结果树中,可以看到本次请求POST data:data={"sm_seq":"201411CM100000017"},Content-Type: application/x-www-form-urlencoded
3、通过WireShark对包结构进行分析,如下图红框所示
二、LR脚本制作
经过了一些曲直,总结了下和大家分享,脚本如下:
情况1:EncType=application/json,原本以为这样写脚本就通过了,但事实并非如此,服务端返回“params error”,参数错误,通过抓包数据对比,可以看出差异在Line-based text data:application/json
情况2:
EncType=application/x-www-form-urlencoded,
Body={\"sm_seq\":\"{CM}\"},由下图可以看出 key的值和value的值不正确
最终修改为:
"EncType=application/x-www-form-urlencoded",
"Body=data={\"sm_seq\":\"{CM}\"}", OK问题解决,能够返程成功的结果。
若有疑问请拍砖。
一、Jmeter
jmeter不涉及到断言之类的操作,只聊http请求。
1、下图为http请求,BodyData中说明发送数据的格式为json
2、在查看结果树中,可以看到本次请求POST data:data={"sm_seq":"201411CM100000017"},Content-Type: application/x-www-form-urlencoded
3、通过WireShark对包结构进行分析,如下图红框所示
二、LR脚本制作
经过了一些曲直,总结了下和大家分享,脚本如下:
web_custom_request("web_custom_request", "URL=http://xxxxxxxxxxxxx/extra_cms_api/get_item_by_seq/RAN1411WUHAN/", "Method=POST", "Resource=0", "RecContentType=application/json", "Referer=", "Mode=HTTP", "EncType=application/x-www-form-urlencoded", "Body=data={\"sm_seq\":\"{CM}\"}", //下面是错误的,通过抓包工具对比,就能定位问题 // 情况1 EncType为json // "EncType=application/json", // 情况2 没有加data= // "Body={\"sm_seq\":\"{CM}\"}", LAST);</span>
情况1:EncType=application/json,原本以为这样写脚本就通过了,但事实并非如此,服务端返回“params error”,参数错误,通过抓包数据对比,可以看出差异在Line-based text data:application/json
情况2:
EncType=application/x-www-form-urlencoded,
Body={\"sm_seq\":\"{CM}\"},由下图可以看出 key的值和value的值不正确
最终修改为:
"EncType=application/x-www-form-urlencoded",
"Body=data={\"sm_seq\":\"{CM}\"}", OK问题解决,能够返程成功的结果。
若有疑问请拍砖。
相关文章推荐
- loadrunner使用web_custom_request post数据
- LoadRunner中web_custom_request 和 web_submit_data的差别
- LoadRunner中web_custom_request 和 web_submit_data的差别
- 软件性能测试_loadrunner之web_custom_request函数做get接口测试
- loadrunner Web_类函数之web_custom_request()
- Loadrunner测试json接口实例以及 web_custom_request 函数详解
- LoadRunner中web_custom_request和web_submit_data的区别
- Loadrunner 关联 web_custom_request综合实例
- LoadRunner 函数之 web_custom_request
- loadrunner之 学习四:web_custom_request()函数
- 【LoadRunner】构建HTTP请求之web_sumbit_data与web_custom_request请求区别
- Loadrunner中web_custom_request使用场景
- Loadrunner Http协议web_submit_data与web_custom_request区别
- Loadrunner测试json接口实例以及 web_custom_request 函数详解
- LoadRunner中web_custom_request和web_submit_data的差别
- 关于loadrunner使用web_add_header添加HTTP信息头(比如Content-Type,token等)和使用web_custom_request()提交json数据
- LoadRunner中web_custom_request和web_submit_data的差别
- [原创]Loadrunner中关联web_custom_request用法
- LoadRunner函数详解之web_custom_request
- loadrunner web_custom_request 脚本处理