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_start和web_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]
相關文章
- 使用Loadrunner進行效能測試
- LoadRunner測試結果分析(1)
- 軟體測試學習教程——LoadRunner實現介面測試
- 如何學習效能測試?LoadRunner小技巧集錦
- Google 單元測試框架Go框架
- 《Google軟體測試之道》 第一章google軟體測試介紹Go
- 效能測試工具LoadRunner你所不知道的內幕
- 使用LoadRunner執行專案效能測試之實操指南
- 效能測試學習筆記:Loadrunner如何進行引數化?筆記
- 軟體測試學習教程——HP Loadrunner12.50安裝教程
- 效能測試常用工具對比:Jmeter與LoadRunner的異同JMeter
- c++效能測試工具:google benchmark入門(二)C++Go
- c++效能測試工具:google benchmark進階(一)C++Go
- 讀Google是如何做軟體測試的Go
- loadrunner12.6快速實戰之透過抓包來獲取app測試指令碼APP指令碼
- 效能測試手冊:一分鐘掌握LoadRunner關聯函式應該放在那函式
- LoadRunner安裝
- 案例實踐:零基礎完成Loadrunner壓力測試,十分鐘教會你
- 一文掌握開源單元測試框架Google Test框架Go
- loadrunner常用函式函式
- Loadrunner學習(一)
- 測試測試測試測試測試測試
- 【資料包】零基礎學習軟體測試 | LoadRunner 和 QTP 入門到精通視訊教程QT
- 黑羽壓測 比 jmeter、locust、loadrunner 更簡便,效能更強JMeter
- Loadrunner效能指標分析指標
- Google 面試題 | 種花Go面試題
- LoadRunner——分析圖詳解(十四)
- loadrunner 唯一序列號
- Google 面試題 | 分餅乾Go面試題
- Google經典面試題解析Go面試題
- 設計師談Google Logo誕生全過程,西邊人西說測試Go
- 測試—測試方法
- 測試測試用
- Loadrunner11 手動關聯
- App測試、Web測試和介面測試一般測試流程APPWeb
- Flutter 學習之路 - 測試(單元測試,Widget 測試,整合測試)Flutter
- 測試面試-測試用例面試
- 介面測試測試流程
- 介面測試,負載測試,併發測試,壓力測試區別負載