(九)Loadrunner编写Http脚本

1、https请求处理

1)录制

lr无法直接录制https请求,如非要录制可使用firefox录制

2)手写脚本

*  脚本前面加web_set_sockets_option("SSL_VERSION","TLS");

*  添加证书

*  直接走http,让开发不开启https

 

2、脚本编写

1)web_url

*  特点:只能发送get请求,不能发送post请求

*  步骤:如下

*  脚本:如下

web_set_sockets_option("SSL_VERSION","TLS");//https安全处理

//检查点
web_reg_find("Text=p5837.jpg",LAST);

web_url("web_url",
"URL=https://api.douban.com/v2/movie/top250?start=0&count=10",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTTP",LAST);

 

2)web_custom_request

*  特点:适用于Get和Post请求

*  使用说明:

*  Get请求,参数直接放在url里,Post请求参数放在body里

*  参数格式:{key:value,key:value},如"Body={\"q\":\"python\",\"start\":0}"

*  参数里int类型不需要加引号

*  body支持json形式参数

*  步骤:如下

*  脚本:如下

web_custom_request("web_custom_request",

"URL=https://api.douban.com/v2/movie/top250?start=0&count=10",

"Method=GET",

"TargetFrame=",

"Resource=0",

"Referer=",

"Mode=HTTP",

"Body=",

LAST);

3)web_submit_form

*  特点:支持get、post请求,且更多用于post请求

*  get请求使用说明

*  post请求使用说明:参数放在itermdata里,如下图

*  get脚本

web_submit_data("web_submit_data",

"Action=https://api.douban.com/v2/movie/top250?start=0&count=10",

"Method=GET",

"TargetFrame=",

"Referer=",

"Mode=HTTP",

ITEMDATA,

LAST);

*  post脚本

web_submit_data("web_submit_data",

"Action=https://api.douban.com/v2/movie/top250",

"Method=POST",

"TargetFrame=",

"Referer=",

"Mode=HTTP",

ITEMDATA,

"Name=start", "Value=0", ENDITEM,

"Name=count", "Value=10", ENDITEM,

LAST);

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值