LoadRunner测试Google Suggest

Google的搜索框是典型的AJAX应用,用户在输入关键字的同时,前端页面通过xmlhttp与后台服务器动态交互,根据用户输入的关键字查找匹配的内容,向用户提示建议的搜索项,也就是所谓的“google suggest”。

如果使用LoadRunner进行测试,采用AJAX(Click and Script)协议录制的话会得到以下脚本:

Action()

{

web_add_cookie_ex("Cookie=PREF=ID=372e76ef6c7e842e:U=1961d03ffd7ab924:NW=1:TM=1264934277:LM=1264934316:S=OYfvCjRzGq1u4u4z; domain=google.cn; path=/", ENDITEM,

"Cookie=NID=31=hwv9eoM6IVUuD1ssILGftThmu8fjLzTdRUZXJTwcEggxBjCoy4Fh3dEsZVLVZ66_WndMz03It6xuCCWAqW28ZCj2r2wJxmfKM4_UHMZGk_mnybPjA6tDdB9HFqVkX1EU; domain=google.cn; path=/", ENDITEM,

"Cookie=SNID=31=BZul31Bwi_B97OMZlOIjZOeSm05tZw_9bw9T4zsT=kqUHVr3rOWtmkOvF; domain=google.cn; path=/verify", ENDITEM,

LAST);

web_browser("www.google.cn",

DESCRIPTION,

ACTION,

"Navigate=http://www.google.cn/",

LAST);

web_edit_field("q",

"Snapshot=t1.inf",

DESCRIPTION,

"Type=text",

"Name=q",

ACTION,

"SetValue=AJAX",

LAST);

web_button("INPUT",

"Snapshot=t2.inf",

DESCRIPTION,

"Type=submit",

"Tag=INPUT",

"ID=",

"Value=Google 搜索",

ACTION,

"UserAction=Click",

LAST);

return 0;

}

可以看到google suggest的AJAX行为并没有被录制下来,从回放日志的服务器返回记录中也找不到google suggest返回结果的踪影。

采用WEB(HTTP/HTML)协议来录制,则得到下面的脚本:

Action()

{

web_add_cookie("PREF=ID=372e76ef6c7e842e:U=1961d03ffd7ab924:NW=1:TM=1264934277:LM=1264934316:S=OYfvCjRzGq1u4u4z; DOMAIN=www.google.cn");

web_add_cookie("NID=31=hwv9eoM6IVUuD1ssILGftThmu8fjLzTdRUZXJTwcEggxBjCoy4Fh3dEsZVLVZ66_WndMz03It6xuCCWAqW28ZCj2r2wJxmfKM4_UHMZGk_mnybPjA6tDdB9HFqVkX1EU; DOMAIN=www.google.cn");

web_url("www.google.cn",

"URL=http://www.google.cn/",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

EXTRARES,

"Url=/extern_js/f/CgV6aC1DThICY24rMAo4V0ACLCswDjgLLCswETgVLCswFjgXLCswFzgFLCswGDgFLCswGTgTLCswJTjKiAEsKzAmOAksKzAnOAQsKzA8OAIsKzBEOAEsKzBFOAEs/qft1hKbTw2Q.js", ENDITEM,

"Url=/favicon.ico", "Referer=", ENDITEM,

"Url=/intl/zh-CN/images/toolbar_animation_20090618.png", ENDITEM,

"Url=/complete/search?hl=zh-CN&xhr=t&q=A&cp=1", ENDITEM,

"Url=/complete/search?hl=zh-CN&xhr=t&q=AJ&cp=2", ENDITEM,

"Url=/complete/search?hl=zh-CN&xhr=t&q=AJA&cp=3", ENDITEM,

"Url=/complete/search?hl=zh-CN&xhr=t&q=AJAX&cp=4", ENDITEM,

LAST);

web_url("csi",

"URL=http://www.google.cn/csi?v=3&s=webhp&action=&e=17259,23361,23603&ei=kMFrS-GQB8qNkAWljIX6AQ&expi=17259,23361,23603&imc=2&imn=2&imp=2&rt=prt.110,xjsls.125,ol.437,iml.250,xjses.437,xjsee.468,xjs.500",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/",

"Mode=HTML",

LAST);

web_url("search",

"URL=http://www.google.cn/search?hl=zh-CN&source=hp&q=AJAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/",

"Snapshot=t2.inf",

"Mode=HTML",

LAST);

web_url("gen_204",

"URL=http://www.google.cn/gen_204?mgmhp=shp1&ct=v&cd=false",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/search?hl=zh-CN&source=hp&q=AJAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Mode=HTML",

LAST);

web_url("csi_2",

"URL=http://www.google.cn/csi?v=3&s=web&action=&e=17259,23361,23603&ei=msFrS5anH8qGkAX5rJDwAw&expi=17259,23361,23603&imc=1&imn=1&imp=1&rt=prt.125,ol.343,iml.156,xjses.375,xjsee.390,xjsls.390,xjs.437",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/search?hl=zh-CN&source=hp&q=AJAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Mode=HTML",

LAST);

return 0;

}

google suggest的行为被录制到第一个web_url的请求中,被作为资源进行HTTP请求。Web_url函数中的EXTRARES表示表示后面的url所指的内容都是作为资源来请求的,LR的帮助文档中是这样说的:

A list of resources generated by non–HTML mechanisms in the Web page. These include the resources requested by Javascript, ActiveX, Java applets and Flash. VuGen‘s Recording Options allow these elements either to be recorded within the current script step (the default mode) or recorded as separate steps (see "Recording in HTML–Based Mode" in the VuGen Online Book).

如果想把google suggest的行为分别录制成一个个的web_url请求,则需要修改录制模式,改为用“URL-Based”模式录制:

Action()

{

web_add_cookie("PREF=ID=372e76ef6c7e842e:U=1961d03ffd7ab924:NW=1:TM=1264934277:LM=1264934316:S=OYfvCjRzGq1u4u4z; DOMAIN=www.google.cn");

web_add_cookie("NID=31=hwv9eoM6IVUuD1ssILGftThmu8fjLzTdRUZXJTwcEggxBjCoy4Fh3dEsZVLVZ66_WndMz03It6xuCCWAqW28ZCj2r2wJxmfKM4_UHMZGk_mnybPjA6tDdB9HFqVkX1EU; DOMAIN=www.google.cn");

web_url("www.google.cn",

"URL=http://www.google.cn/",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTTP",

LAST);

web_concurrent_start(NULL);

web_url("logo_cn.gif",

"URL=http://www.google.cn/intl/zh-CN/images/logo_cn.gif",

"Resource=1",

"RecContentType=image/gif",

"Referer=http://www.google.cn/",

"Snapshot=t2.inf",

LAST);

web_url("cn_icp.gif",

"URL=http://www.google.cn/intl/zh-CN_cn/images/cn_icp.gif",

"Resource=1",

"RecContentType=image/gif",

"Referer=http://www.google.cn/",

"Snapshot=t3.inf",

LAST);

web_concurrent_end(NULL);

web_concurrent_start(NULL);

web_url("qft1hKbTw2Q.js",

"URL=http://www.google.cn/extern_js/f/CgV6aC1DThICY24rMAo4V0ACLCswDjgLLCswETgVLCswFjgXLCswFzgFLCswGDgFLCswGTgTLCswJTjKiAEsKzAmOAksKzAnOAQsKzA8OAIsKzBEOAEsKzBFOAEs/qft1hKbTw2Q.js",

"Resource=1",

"RecContentType=text/javascript",

"Referer=http://www.google.cn/",

"Snapshot=t4.inf",

LAST);

web_url("nav_logo7.png",

"URL=http://www.google.cn/images/nav_logo7.png",

"Resource=1",

"RecContentType=image/png",

"Referer=http://www.google.cn/",

"Snapshot=t5.inf",

LAST);

web_url("favicon.ico",

"URL=http://www.google.cn/favicon.ico",

"Resource=1",

"RecContentType=image/x-icon",

"Referer=",

"Snapshot=t6.inf",

LAST);

web_concurrent_end(NULL);

web_url("csi",

"URL=http://www.google.cn/csi?v=3&s=webhp&action=&e=17259,23361,23603&ei=9MRrS62DC8yTkAX285SPAw&expi=17259,23361,23603&imc=2&imn=2&imp=2&rt=prt.94,xjsls.109,ol.437,iml.328,xjses.452,xjsee.484,xjs.515",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/",

"Mode=HTTP",

LAST);

web_concurrent_start(NULL);

web_url("toolbar_animation_20090618.png",

"URL=http://www.google.cn/intl/zh-CN/images/toolbar_animation_20090618.png",

"Resource=1",

"RecContentType=image/png",

"Referer=http://www.google.cn/",

"Snapshot=t7.inf",

LAST);

web_url("search",

"URL=http://www.google.cn/complete/search?hl=zh-CN&xhr=t&q=A&cp=1",

"Resource=1",

"RecContentType=application/json",

"Referer=http://www.google.cn/",

"Snapshot=t8.inf",

LAST);

web_url("search_2",

"URL=http://www.google.cn/complete/search?hl=zh-CN&xhr=t&q=Aj&cp=2",

"Resource=1",

"RecContentType=application/json",

"Referer=http://www.google.cn/",

"Snapshot=t9.inf",

LAST);

web_url("search_3",

"URL=http://www.google.cn/complete/search?hl=zh-CN&xhr=t&q=AjA&cp=3",

"Resource=1",

"RecContentType=application/json",

"Referer=http://www.google.cn/",

"Snapshot=t10.inf",

LAST);

web_url("search_4",

"URL=http://www.google.cn/complete/search?hl=zh-CN&xhr=t&q=AjAX&cp=4",

"Resource=1",

"RecContentType=application/json",

"Referer=http://www.google.cn/",

"Snapshot=t11.inf",

LAST);

web_concurrent_end(NULL);

lr_think_time(14);

web_url("search_5",

"URL=http://www.google.cn/search?hl=zh-CN&source=hp&q=AjAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/",

"Snapshot=t12.inf",

"Mode=HTTP",

LAST);

web_url("nav_logo7.png_2",

"URL=http://www.google.cn/images/nav_logo7.png",

"Resource=1",

"RecContentType=image/png",

"Referer=http://www.google.cn/search?hl=zh-CN&source=hp&q=AjAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Snapshot=t13.inf",

LAST);

web_url("gen_204",

"URL=http://www.google.cn/gen_204?mgmhp=shp1&ct=v&cd=false",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/search?hl=zh-CN&source=hp&q=AjAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Mode=HTTP",

LAST);

web_url("csi_2",

"URL=http://www.google.cn/csi?v=3&s=web&action=&e=17259,23361,23603&ei=BMVrS-fpFMqGkAWXrpzwAw&expi=17259,23361,23603&imc=1&imn=1&imp=0&rt=prt.468,ol.499,iml.468,xjses.546,xjsee.561,xjsls.561,xjs.608",

"Resource=0",

"RecContentType=text/html",

"Referer=http://www.google.cn/search?hl=zh-CN&source=hp&q=AjAX&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&oq=",

"Mode=HTTP",

LAST);

return 0;

}

这样录制下来的脚本会长很多。Google suggest的AJAX行为被分别录制成一个个的web_url请求,并且放在web_concurrent_startweb_concurrent_end之间。关于web_concurrent_start函数的描述,可以参考LR帮助文档:

The web_concurrent_start function marks the beginning of a concurrent group. All functions within the group are executed concurrently. The end of the group is marked by the web_concurrent_end function. Within the concurrent group, you may include Action functions and several Service functions.

Note that the functions included within the concurrent group are not executed immediately. Instead they are registered for concurrent execution. When the concurrent group is closed, all of the functions registered as concurrent are executed together.

Concurrent中的函数都会先注册,而不是马上执行,直到web_concurrent_end才一起执行,这个从回放的日志也可以看出来:

Action.c(73): web_concurrent_start was successful         [MsgId: MMSG-26392]

Action.c(75): Registering web_url("toolbar_animation_20090618.png") was successful         [MsgId: MMSG-26390]

Action.c(83): Registering web_url("search") was successful     [MsgId: MMSG-26390]

Action.c(91): Registering web_url("search_2") was successful        [MsgId: MMSG-26390]

Action.c(99): Registering web_url("search_3") was successful        [MsgId: MMSG-26390]

Action.c(107): Registering web_url("search_4") was successful      [MsgId: MMSG-26390]

Action.c(115): web_concurrent_end was successful, 8506 body bytes, 1355 header bytes, 84 chunking overhead bytes     [MsgId: MMSG-26385]

时间: 2024-09-30 18:48:50

LoadRunner测试Google Suggest的相关文章

LoadRunner测试AJAX

什么是AJAX? Ajax, shorthand for Asynchronous JavaScript and XML, is a web development technique for creating interactive web applications. The intent is to make web pages feel more responsive by exchanging small amounts of data with the server behind th

运用Loadrunner测试Mysql数据库性能 TRON?极客

1.前言 针对数据库的性能测试,loadrunner本身支持sql server和oracle数据库,这两种数据库可以用loadrunner直接录制进行测试.而我们项目中使用的是mysql数据库,针对用 loadrunner测试mysql数据库的方法网上也有很多介绍文章,主要有两种方案.一种是利用ODBC连接测试mysql,但是这种方法配置比较麻 烦,如果要录制的话需要安装支持ODBC连接的查询分析器,这工具不好找,能找到的也只能算凑合能用.如果大家有兴趣试试这种方法,可以上网搜搜,学习配 置一

loadrunner测试TCP协议服务器性能

最近对服务器的性能感兴趣,于是开始研究了一阵子loadrunner如何做采用TCP协议交互的服务器的性能测试,对loadrunner不是很熟悉,所以一开始也走了一些弯路,现将学习的过程记录下来,为以后做参考吧. TCP协议的服务器的性能测试,我想大家都会选择loadrunner的winsocket协议进行测试,我也是采用此种方式.下面将逐一记录如何使用此协议做性能测试. 1.采用DLL文件方式进行测试 由于与服务器连接的客户端的DLL文件我手头有,同时其对应的头文件也有,所以一开始试想的是采用l

LoadRunner测试50人同时登陆下单

LoadRunner测试50人同时登陆下单 一.LoadRunner简介 LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找问题,LoadRunner能够对整个企业架构进行测试.企业使用LoadRunner能最大限度地缩短测试时间,优化性能和加速应用系统的发布周期. LoadRunner可适用于各种体系架构的自动负载测试,能预测系统行为并评估系统性能. 二.名词解释 1.集合 集合点的意思时等到特定的用户数后再一起执行某

LoadRunner测试ajax框架,回放后系统中没有产生数据解决方法

LoadRunner测试ajax框架的系统时,录制回放都没有报错,但是回放后系统中没有产生数据,数据始终不能写入数据库.查了一下原因,应该是录制的脚本不完善的问题,因为JS是在客户端执行的程序,LR只能监控客户机与服务器之前的通信. 解决方法: Recording options> HTTP Properites> Advanced > Headers: 选择"Record headers not in list", 然后点ok. 重新录制一遍脚本,会发现脚本里多出一

uva 1462 - Fuzzy Google Suggest(字典树+dfs)

题目链接:uva 1462 - Fuzzy Google Suggest 题目大意:模拟google的模糊搜索,给定给一个字符串集合,然后有n次搜索,每次有一个整数x和一个字符串,表示可以对字符串进行x次修改,包括增加.修改和删除一个字符,问修改后的字符可能是字符集中有多少个字符串的前缀. 解题思路:先建立字典树,对于每次搜索,在字典树上进行dfs,根据参数x和字符串匹配的位置进行处理,对于匹配到末尾的位置标记为2,然后对于第二次dfs,搜索每个分支上最早出现2的位置即可. #include <

LoadRunner测试结果分析02 转载至zhangzhe的新浪博客

LoadRunner测试结果分析之我见 上述测试过程的重点在于事务,而LoadRunner生成的测试结果图并不局限于事务上,其中还有是关于Vusers.Errors.Web Resources.Web Page diagnostics的测试图. 1. 对于Vusers的测试图有3种:Running Vusers.Vusers Summary.Rendezvous,其中Running Vusers是关于虚拟用户加压.施压.减压的情况图: Vusers Summary是用户运行结果的综述图:Rend

loadrunner测试c/s架构的应用系统

用LoadRunner测试c/s架构的软件,怎样去选择协议,困扰了我很久,看到这篇文章,感觉有点收获,所以特意转了过来,希望对大家有用. 首先,什么是协议?协议无非就是一个约定,关于数据包发送的格式的约定,就是说如果大家都这样发送,那么通信就能够成功,如果大家都各按各的来,那么就没办法进行通信了.那么接下来就是LR录制时的工作原理了,LR的录制和WR不一样,它不关心你的对象识别什么的,不关心你的什么窗口之类的,LR有一个Agent进程,来专门监控客户端和服务器之间的通信,然后用自己的函数进行录制

LoadRunner测试结果分析01 转载至zhangzhe的新浪博客

LoadRunner测试结果分析之我见 LoadRunner生成测试结果并不代表着这次测试结果的结束,相反,这次测试结果的重头戏才刚刚开始.如何对测试结果进行分析,关系着这次测试的成功与否.网上关于LoadRunner测试结果如何分析的介绍相当匮乏,在总结他人的观点和自己的实验体会基础上来介绍如何进行LoadRunner测试结果分析. 1. LoadRunner测试结果分析的第一步应该是查看分析综述(Analysis Summary),其包括统计综述(Statistics Summary).事务