LoadRunner檢查點使用小結(2)

發表于:2011-12-14來源:未知作者:娃娃點擊數: 標簽:loadrunner
Resource=0, RecContentType=text/html, Referer=, Snapshot=t1.inf, Mode=HTML, LAST); // Set up check for su cc essful login by looking for Welcome web_reg_find(Text=Welcome, SaveCount=Welcome_Count, LAS

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

LAST);

// Set up check for successful login by looking for "Welcome"

web_reg_find("Text=Welcome",

"SaveCount=Welcome_Count",

LAST);

// Now log in

web_submit_form("login.pl",

"Snapshot=t2.inf",

ITEMDATA,

"Name=username", "Value=jojo", ENDITEM,

Name=password", "Value=bean", ENDITEM,

"Name=login.x", "Value=35", ENDITEM,

"Name=login.y", "Value=14", ENDITEM,

LAST);

// Check result

if (atoi(lr_eval_string("{Welcome_Count}")) > 0){ //判斷如果Welcome字符串出現次數大于0

    lr_output_message("Log on successful."); }//在日志中輸出Log on successful

else{ //如果出現次數小于等于

lr_error_message("Log on failed"); //在日志中輸出Log on failed

return(0); }

我覺得這個方法非常有用,我們可以舉一反三,應用到我們實際的項目

注:在錄制過程中添加的檢查點,用到的函數是web_reg_find(),且參數只有“Text=”

3、web_image_check()函數參數說明:

web_image_check("web_image_check","Alt=","Src=",LAST);

參數解釋:“Alt”和“Src”的值直接取該圖片在網頁源代碼中相應參數的值;

注意事項:使用該函數時,要在Vuser->Run-Tme Settings中勾選Enable Image and text check,具體操作請看web_find()中的注意事項。

經過測試,該函數用到查找內容前面或后面,都不影響查找結果。

舉例說明(腳本)

該腳本記錄的是登陸系統后退出的操作,在腳本中用到atoi()函數和lr_eval_string(”{SaveCount定義的變量}”)兩個函數結合使用,判斷查找內容出現的次數是否大于0,若大于0,則輸入登錄成功的信息。

vuser_init()

{

    web_url("xjcost",

    "URL=http://gczj-server8:9205/xjcost/",

    "Resource=0",

    "RecContentType=text/html",

    "Referer=",

    "Snapshot=t1.inf",

    "Mode=HTML",

    EXTRARES,

    "Url=jsp/images/index/index.swf", ENDITEM,

    "Url=jsp/images/index/xxfb2.gif", ENDITEM,

     "Url=jsp/images/index/ywpt2.gif", ENDITEM,

     LAST);

     web_url("userAction.struts",

     "URL=http://gczj-server8:9205/xjcost/userAction.struts?actionType=reLogin",

     "Resource=0",

     "RecContentType=text/html",

     "Referer=",

    "Snapshot=t2.inf",

     "Mode=HTML",

     LAST);

    return 0;

}

Action()

{

    lr_start_transaction("Log_on");

    lr_rendezvous("Log_on");

     web_add_cookie("userAccount=admin; DOMAIN=gczj-server8");

    web_reg_find("Text=歡迎您",

    "SaveCount=歡迎您_Count",

     LAST);

    web_image_check("web_image_check",

    "Src=/xjcost/jsp/images/index1/edit_01.gif",

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97