• Loadrunner中web_custom_request使用场景


    其中有一段从服务器段动态返回的字符串需要重新提交给服务器(见红色标注)
    
    录制自动生成的脚本是:
    web_submit_data("generateYfLstAction.do", 
        "Action=http://172.32.234.213:8001/SAPIR/commission/generateYfLstAction.do", 
        "Method=POST", 
        "TargetFrame=", 
        "RecContentType=text/html", 
        "Referer=http://172.32.234.213:8001/SAPIR/commission/listCommissionAction.do", 
        "Snapshot=t10.inf", 
        "Mode=HTML", 
        ITEMDATA, 
        "Name=proc", "Value=page", ENDITEM, 
        "Name=companyCode", "Value=2000", ENDITEM, 
        "Name=tradeZone", "Value=", ENDITEM, 
        "Name=trade", "Value=", ENDITEM, 
        "Name=genDateBegin", "Value=2007-06-18", ENDITEM, 
        "Name=genDateEnd", "Value=2007-07-18", ENDITEM, 
        "Name=tradeLane", "Value=", ENDITEM, 
        "Name=actvyDateBegin", "Value=", ENDITEM, 
        "Name=actvyDateEnd", "Value=", ENDITEM, 
        "Name=svcLoopCodeBase", "Value=", ENDITEM, 
        "Name=svvdBase", "Value=", ENDITEM, 
        "Name=portCodeBase", "Value=", ENDITEM, 
        "Name=svcLoopCode", "Value=", ENDITEM, 
        "Name=svvd", "Value=", ENDITEM, 
        "Name=portCode", "Value=", ENDITEM, 
        "Name=commMode", "Value=", ENDITEM, 
        "Name=commType", "Value=", ENDITEM, 
        "Name=commClass", "Value=", ENDITEM, 
        "Name=blRefCode", "Value=", ENDITEM, 
        "Name=totalPage", "Value=1211", ENDITEM, 
        "Name=currentPage", "Value=5", ENDITEM, 
        "Name=downloadInd", "Value=0", ENDITEM, 
        "Name=page", "Value=5", ENDITEM, 
        "Name=commYfLstIds", "Value=1902189472274599&9999203000&Cargo&USD&SAL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1902189472274599&9999203000&Operation&USD&FPOL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903184294047663&9999203000&Cargo&USD&SAL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903184294047663&9999203000&Operation&USD&FPOL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1902644201920888&9999203000&Cargo&USD&SAL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1902644201920888&9999203000&Operation&USD&FPOL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903191810240974&9999203000&Cargo&USD&SAL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903191810240974&9999203000&Operation&USD&FPOL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903191810240966&9999203000&Cargo&USD&SAL&1&1", ENDITEM, 
        "Name=commYfLstIds", "Value=1903191810240966&9999203000&Operation&USD&FPOL&1&1", ENDITEM, 
        "Name=companyCode", "Value=2000", ENDITEM, 
        LAST);
        
    
    因为这些value都是动态提交,因此需要改用web_custom_request函数
    修改后的脚本如下:
    web_custom_request("generateYfLstAction.do", 
         "URL=http://172.32.234.213:8001/SAPIR/commission/generateYfLstAction.do", 
          "Method=POST", 
          "Resource=0", 
          "RecContentType=text/html", 
          "Referer=http://172.32.234.213:8001/SAPIR/commission/listCommissionAction.do", 
          "Snapshot=t27.inf", 
          "Mode=HTTP", 
          "Body=proc=page&companyCode=2000&tradeZone=&trade=&genDateBegin=2007-06-18&genDateEnd=2007-07-18&tradeLane=&actvyDateBegin=&actvyDateEnd=&svcLoopCodeBase=&svvdBase=&portCodeBase=&svcLoopCode=&svvd=&portCode=&commMode=&commType=&commClass=&blRefCode=&totalPage=1206&currentPage=3&downloadInd=0&page=3&commYfLstIds=1902457907718192&9999203000&Cargo&USD&SAL&1&1&commYfLstIds=1902457907718192&9999203000&Operation&USD&FPOL&1&1&commYfLstIds="1903242276105507&9999203000&Operation&USD&FPOL&1&1&commYfLstIds=1903242276105522&9999203000&Cargo&USD&SAL&1&1&commYfLstIds=1903242276105522&9999203000&Operation&USD&FPOL&1&1&commYfLstIds=1902525553448997&9999203000&Cargo&USD&SAL&1&1&commYfLstIds=1902525553448997&9999203000&Operation&USD&FPOL&1&1&companyCode=2000", 
           LAST);
    
    但是这个动态字符串中包含“&”,和函数中默认&代表连接符冲突,因此提交服务器端是报错。
    我手工把body段的凡是commYfLstIds=后不是连接符的“&”都替换成%26,才能提交成功(手动修改后代码如下)
    
    "Body=proc=page&companyCode=2000&tradeZone=&trade=&genDateBegin=2007-06-18&genDateEnd=2007-07-18&tradeLane=&actvyDateBegin=&actvyDateEnd=&svcLoopCodeBase=&svvdBase=&portCodeBase=&svcLoopCode=&svvd=&portCode=&commMode=&commType=&commClass=&blRefCode=&totalPage=1206&currentPage=3&downloadInd=0&page=3&commYfLstIds=1902457907718192%269999203000%26Cargo%26USD%26SAL%261%261&commYfLstIds=1902457907718192%269999203000%26Operation%26USD%26FPOL%261%261&commYfLstIds="1903242276105507%269999203000%26Operation%26USD%26FPOL%261%261&commYfLstIds=1903242276105522%269999203000%26Cargo%26USD%26SAL%261%261&commYfLstIds=1903242276105522%269999203000%26Operation%26USD%26FPOL%261%261&commYfLstIds=1902525553448997%269999203000%26Cargo%26USD%26SAL%261%261&commYfLstIds=1902525553448997%269999203000%26Operation%26USD%26FPOL%261%261&companyCode=2000", 
    我是把服务器动态返回的“1902189472274599&9999203000&Cargo&USD&SAL&1&1”这类记录都进行了动态关联,因此请问大家如何才能让lr自动将动态关联所得参数中出现的“&”转义变成%26呢?
  • 相关阅读:
    ABP框架应用-MySQL数据库集成
    redis初识
    MySQL高级学习笔记
    Linux安装apache
    学习jvm(一)--java内存区域
    HashTable、HashMap与ConCurrentHashMap源码解读
    Linux安装禅道项目管理软件
    设计模式之六大原则
    设计模式之策略模式
    设计模式之分类
  • 原文地址:https://www.cnblogs.com/qmfsun/p/4900232.html
Copyright © 2020-2023  润新知