lily_liuliu 发表于 2012-7-22 21:21:47

loadrunner新手:录制百度搜索脚本,回放报错

loadrunner新手一枚
今天试着录制了百度查询(输入查询条件what)的脚本,回放时报错:
Action.c(276): Continuing after 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=what&p=0&pn=1"          
在网上找了下解决办法:
http://www.51testing.com/?13997/viewspace-5083

参照着将脚本修改为:
web_convert_param("encoderesult",
                "SourceString={what}",
                "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}&rsv_bp=0&rsv_spt=3&inputT=2422",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://www.baidu.com/",
                "Snapshot=t9.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=what&p=0&pn=1",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=2422",
                "Mode=HTTP",
                LAST);// 这里的ural 和referer中出现的what分别保持原值和换成{encoderesult}后都重新回放了一下,还是会报204的错

请问哪位知道问题出在哪儿么?小女子刚刚接触性能测试,还请知道方法的前辈们不吝指导啊, 在此谢过! :)

踏雪飞狐 发表于 2012-7-23 10:31:17

我在我机子上试了,正常通过啊,所以不知道你什么问题

云层 发表于 2012-7-23 10:48:48

新手找尽量简单的例子来做,baidu这种有ajax技术会让你有些茫然

lily_liuliu 发表于 2012-7-23 16:06:18

回复 2# 踏雪飞狐


    哦?这就怪了
   方便把你的脚本贴出来我学习下么? 不知道是不是哪个细节我出错了
   谢谢回复:)

lily_liuliu 发表于 2012-7-23 16:06:41

回复 3# 云层


    哦 好的
谢谢指导:)

yayating 发表于 2012-7-23 17:26:05

其实204代表已经返回成功了,只是返回的body里面没有消息而已,这个应该不影响测试的~~
你在浏览器中直接输入这个URL=http://c.baidu.com/c.gif?t=0&q=what&p=0&pn=1链接是打不开网页的
还有如果你只是查询what关键词,将下面的SourceString={what}中的大括号可以去掉的~~:loveliness:
web_convert_param("encoderesult",
                "SourceString=what",
                "SourceEncoding=HTML",
                "TargetEncoding=URL",
                LAST);

踏雪飞狐 发表于 2012-7-24 15:12:22

Action()
{

        lr_think_time(15);

        web_url("s",
                "URL=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://www.baidu.com/",
                "Snapshot=t2.inf",
                "Mode=HTTP",
                LAST);

        web_concurrent_start(NULL);

        web_url("common-core-1.1.js",
                "URL=http://s1.bdstatic.com/r/www/cache/global/js/common-core-1.1.js",
                "Resource=1",
                "RecContentType=application/javascript",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_url("baidu_jgylogo3.gif",
                "URL=http://www.baidu.com/img/baidu_jgylogo3.gif",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_url("c.gif",
                "URL=http://c.baidu.com/c.gif?t=0&q=what&p=0&pn=1",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                "Mode=HTTP",
                LAST);

        web_url("logic-1.2.js",
                "URL=http://s1.bdstatic.com/r/www/cache/global/js/logic-1.2.js",
                "Resource=1",
                "RecContentType=application/javascript",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_concurrent_end(NULL);

        web_add_cookie("BAIDUID=398938D4424E8530C9264AA22ED1CD1B:FG=1; DOMAIN=nsclick.baidu.com");

        web_concurrent_start(NULL);

        web_url("v.gif",
                "URL=http://nsclick.baidu.com/v.gif?pid=201&pj=www&fm=alzd&tab=zd&is_n_fld=replynum_ala&path=http%3A%2F%2Fwww.baidu.com%2Fs%3Fwd%3Dwhat%26rsv_bp%3D0%26rsv_spt%3D3%26inputT%3D4516&wd=what&rsv_sid=1288_1329_1266_1229_1324_1208_1342_1185_1280_1178_1286_1320_1293_1331&t=1343113850062",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_url("sound.gif",
                "URL=http://dict.baidu.com/bddict/img/sound.gif",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_url("bg-1.0.0.gif",
                "URL=http://s1.bdstatic.com/r/www/img/bg-1.0.0.gif",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_url("v.gif_2",
                "URL=http://nsclick.baidu.com/v.gif?pid=201&pj=www&fm=alzd&tab=zd&is_n_fld=bestanswer_ala&path=http%3A%2F%2Fwww.baidu.com%2Fs%3Fwd%3Dwhat%26rsv_bp%3D0%26rsv_spt%3D3%26inputT%3D4516&wd=what&rsv_sid=1288_1329_1266_1229_1324_1208_1342_1185_1280_1178_1286_1320_1293_1331&t=1343113850109",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_concurrent_end(NULL);

        web_add_cookie("BAIDUID=398938D4424E8530C9264AA22ED1CD1B:FG=1; DOMAIN=sclick.baidu.com");

        web_url("w.gif",
                "URL=http://sclick.baidu.com/w.gif?q=what&fm=se&T=1343113883&y=5DFF1FF6&rsv_sid=1288_1329_1266_1229_1324_1208_1342_1185_1280_1178_1286_1320_1293_1331&cid=0&qid=ee035fc4145c3727&t=1343113850187&path=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                LAST);

        web_add_cookie("BAIDUID=398938D4424E8530C9264AA22ED1CD1B:FG=1; DOMAIN=share.baidu.com");

        web_url("getsharenum",
                "URL=http://share.baidu.com/getsharenum?urls=15713695991992678161,16144205220161283122,18384122405274507982,7001184522661984374,16969083979281769037,18308325662117112975&callback=bds.se.like.giveData",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=http://www.baidu.com/s?wd=what&rsv_bp=0&rsv_spt=3&inputT=4516",
                "Snapshot=t3.inf",
                "Mode=HTTP",
                LAST);

        return 0;
}
这是action的代码,init的我就不贴了

lily_liuliu 发表于 2012-7-25 17:48:40

回复 6# yayating


    :P   3Q

云层 发表于 2012-7-25 19:10:27

不建议参考7楼的脚本

tang9902 发表于 2013-6-17 19:51:02

回复 9# 云层


    那他那个脚本应该怎么修改。我也遇见上面第问题来。求解。
页: [1]
查看完整版本: loadrunner新手:录制百度搜索脚本,回放报错