我在做 b/s 测试 ,请问如何保存从 服务器 传回来的 http 头的信息,怎么能得到 http 状态,和状态 200 进行比较? 后来,我" name="description" />

LR中判断HTTP返回状态

发表于:2008-09-19来源:作者:点击数: 标签:httpHTTPHttp状态判断
有天,有个人问: MI LY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-bidi-font-family: Tahoma">我在做 b/s 测试 ,请问如何保存从 服务器 传回来的 http 头的信息,怎么能得到 http 状态,和状态 200 进行比较? 后来,我
有天,有个人问:MILY: 宋体; mso-ascii-font-family: Tahoma; mso-hansi-font-family: Tahoma; mso-bidi-font-family: Tahoma">我在做b/s测试,请问如何保存从服务器传回来的http头的信息,怎么能得到http状态,和状态200进行比较?

后来,我给出的代码如下:

Action()

{int i;

       // [WCSPARAM WCSParam_Text1 3 200] Parameter {WCSParam_Text1} created by Correlation Studio

       web_reg_save_param("WCSParam_Text1",

              "LB=1.1 ",

              "RB= ",

              "Ord=1",

              "RelFrameId=1",

              "Search=Headers",

              "IgnoreRedirections=Yes",

              LAST);

       web_url("www.hao123.com",

              "URL=http://www.hao123.com/",

              "Resource=0",

              "RecContentType=text/html",

              "Referer=",

              "Snapshot=t1.inf",

              "Mode=HTML",

              LAST);

  i=atoi(lr_eval_string("{WCSParam_Text1}"));

if (i == 200)

       lr_log_message("终于成功了!!我不容易呀!!!");

       else

       lr_log_message("唉,又失败了,不过这才是正常的! ");

       return 0;

}

后来查了帮助,看到如下方法才好:

Action()

{

int HttpRetCode;

       web_url("www.hao123.com",

              "URL=http://www.hao123.com/",

              "Resource=0",

              "RecContentType=text/html",

              "Referer=",

              "Snapshot=t1.inf",

              "Mode=HTML",

              LAST);

 

    HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);

 

if (HttpRetCode == 200)

       lr_log_message("终于成功了!!我不容易呀!!!");

       else

       lr_log_message("唉,又失败了,不过这才是正常的! ");

       return 0;

}

 

关于函数,偶不说了,查看帮助,清楚着哩

原文转自:http://www.ltesting.net