(九)Loadrunner编写Http脚本

    xiaoxiao2023-11-23  130

    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)