需求要求:这两天试用Windows sockets 协议编写脚本,突然说要测试应用服务压力,后面与开发协商是用http协议之后,没有脚本可以录制,从loadrunner自带函数查可以使用web_custom_request函数编写,之后通过火狐插件:HttpRequester参考,再加网上前辈提供帮助,之后编写如下脚本:

测试并且通过。
发现问题,在loadrunner中压测能返回报文,并且查找条件也能正确。但发现数据库查出结果,中文出现乱码;希望谁能指点下;
Action()
{
  char* Recode="000000";  //增加判断正确条件
   char* WebRecode; //定义关联函数取值
 web_reg_save_param("yanz",
  "LB=
  "RB=
  LAST);
    web_reg_find("Text=
                 LAST);
 lr_start_transaction("ABC_试算");
web_custom_request("web_custom_request",
      "URL=【ip】", //报文IP地址
      "METhod=post",
      "Resource=0",
      "Referer=",
      "Mode=HTML",
       "RecContentType=application/json",
      "EncType= text/xml;charset=UTF-8",
      "Body="
      //报文内容
      "
      "
    "
    "
    "
    "
    ........................
    ........................
    ""
    "
WebRecode = lr_eval_string( "{yanz}" ) ;
if(strcmp(Recode,WebRecode)==0)   //试用判断函数
 {
      lr_end_transaction("ABC_试算", LR_PASS);
 }
    else
 {
  lr_end_transaction("ABC_试算", LR_FAIL);
lr_output_message( "We are on iteration #%s", lr_eval_string( "{yanz}" ) ); }
    return 0;
}
//字符串比较判断。
if(strcmp(lr_eval_string("{www}"),"登陆成功")==0)
    {
        lr_end_sub_transaction("login",LR_PASS);
    }
    else
    {
        lr_end_sub_transaction("login",LR_FAIL);
    }
注:
extern int strcmp(const char *s1,const char *s2);                                                本文名称:laodRuner中Http协议接口编写-创新互联
转载来于:http://www.scyingshan.cn/article/dododh.html

 建站
建站
 咨询
咨询 售后
售后
 建站咨询
建站咨询 
 