淘宝商城(天猫)高级技术专家.3年研发+3年性能测试调优/系统测试+4年团队管理与测试架构、研发系统实践. 新舞台新气象, 深化测试基础架构及研发架构,希望能在某个技术领域成为真正的技术大牛。欢迎荐才http://bbs.51testing.com/viewthread.php?tid=120496&extra=&page=1 .邮件: jianzhao.liangjz@alibaba-inc.com,MSN:liangjianzhao@163.com.微博:http://t.sina.com.cn/1674816524

web_convert_param 函数在baidu.com搜索测试上的使用

上一篇 / 下一篇  2007-03-16 21:07:35 / 个人分类:loadrunner性能测试经验

html方式录制baidu.com,比如查询”linux技巧”,则在runtime-viewer看到查询关键词并非”linux技巧

改用url 模式录制,代码如后:

web_url("s",            "URL=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",

             "Resource=0",

             "RecContentType=text/html",

             "Referer=http://www.baidu.com/",

             "Snapshot=t4.inf",

             "Mode=HTTP",

             LAST);

 web_url("c.gif",

             "URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",

             "Resource=0",

             "RecContentType=text/html",            "Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",

             "Mode=HTTP",

             LAST);

 

回放出错,经ethreal截包,确有:http 204错误。

 

Action.c(28): Error -26563: Non-empty response body is invalid with HTTP Status Code 204 (No Content) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"     [MsgId: MERR-26563]

Action.c(28): t=1560ms: 1-byte response body for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9" (RelFrameId=1)

Action.c(28):     \x00

Action.c(28): Warning -26652: Response body length (1) does not match the Content-Length header specification (0) for "http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9"       [MsgId: MWAR-26652]

Action.c(28): web_url("c.gif") highest severity level was "ERROR", 1 body bytes, 112 header bytes         [MsgId: MMSG-26388]

 

为了参数化以及更正错误,正确的代码如后:

web_convert_param("encoderesult", "SourceString={keyword}","SourceEncoding=HTML",

        "TargetEncoding=URL", LAST);

      lr_log_message("encode=%s",lr_eval_string("{encoderesult}"));

      web_url("s",

             "URL=http://www.baidu.com/s?wd={encoderesult}&cl=3",

             "Resource=0",

             "RecContentType=text/html",

             "Referer=http://www.baidu.com/",

             "Snapshot=t4.inf",

             "Mode=HTTP",

             LAST);        

      lr_continue_on_error(LR_ON_ERROR_CONTINUE );

      web_url("c.gif",

             "URL=http://c.baidu.com/c.gif?t=0&q=linux%BC%BC%C7%C9",

             "Resource=0",

             "RecContentType=text/html",            "Referer=http://www.baidu.com/s?wd=linux%BC%BC%C7%C9&cl=3",

             "Mode=HTTP",

             LAST);


TAG:

atmosphere162的个人空间 引用 删除 atmosphere162   /   2014-02-18 17:25:31
万分感谢,这个问题困扰我很久了,终于解决了
阿里巴巴一个测试架构师 引用 删除 liangjz   /   2008-06-02 13:49:23
呵呵,这个编码格式有1年多了,现在是否这样,需要判断下http 编码格式
wzw1982的个人空间 引用 删除 wzw1982   /   2008-06-02 02:40:54
就是不使用  lr_continue_on_error(LR_ON_ERROR_CONTINUE )  不明白按照这种录制模式请求web_url("c.gif", 会报错
wzw1982的个人空间 引用 删除 wzw1982   /   2008-06-02 02:30:07
按照楼主的做法 把%BC%BC%C7%C9全部替换成{encoderesult}还是会报204错 经过这个函数转换后技巧这两个字最后应该还是以%BC%BC%C7%C9发送到服务器端的 这个204错误不知道怎么解决 但是这函数可以解决参数话的问题
 

评分:0

我来说两句

Open Toolbar