loadrunner中web_reg_find使用使用方法

來源:互聯網
上載者:User

標籤:session   字串   runner   cti   number   font   failed   mod   ted   

Java文法:int object.reg_find( String text, String[] argumentList ); (例子:略)

C文法:int web_reg_find( const char *attribute_list, LAST );

Example 1搜尋文本字串“world”,如果沒有搜尋到,則函數搜尋失敗,指令碼停止執行:

    web_url("My97DatePicker.html_2",
        "URL=http://www.****/thirdparty/My97DatePicker/My97DatePicker.html",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
        "Snapshot=t5.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=lang/zh-cn.js", ENDITEM,
        "Url=skin/whyGreen/datepicker.css", ENDITEM,
        "Url=skin/default/datepicker.css", ENDITEM,
        "Url=skin/default/img.gif", ENDITEM,
        LAST);

    web_reg_find("Text=world",

    LAST );

    web_submit_data("login.do",
        "Action=http://www.****/jjh/dacms/login.do",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
        "Snapshot=t6.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=username", "Value=****", ENDITEM,
        "Name=password", "Value=****", ENDITEM,
        "Name=submit.x", "Value=32", ENDITEM,
        "Name=submit.y", "Value=16", ENDITEM,
        LAST);

失敗提示資訊為:

Action.c(69): Error -26366: "Text=world" not found for web_reg_find      [MsgId: MERR-26366]
Action.c(69): web_submit_data("login.do") highest severity level was "ERROR", 4261 body bytes, 315 header bytes, 13 chunking overhead bytes      [MsgId: MMSG-26387]

Example 2

例2與例1相同,但由於使用了SaveCount,所以在失敗時不會停止指令碼執行。相反,錯誤在代碼中處理。

web_url("My97DatePicker.html_2",
        "URL=http://www.****/thirdparty/My97DatePicker/My97DatePicker.html",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
        "Snapshot=t5.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=lang/zh-cn.js", ENDITEM,
        "Url=skin/whyGreen/datepicker.css", ENDITEM,
        "Url=skin/default/datepicker.css", ENDITEM,
        "Url=skin/default/img.gif", ENDITEM,
        LAST);

    web_reg_find("Text=world",
        "SaveCount=world_Count",
        LAST );

     if (atoi(lr_eval_string("{world_Count}")) > 0){
        lr_output_message("Log on successful.");
        }

     else{
        lr_output_message("output:Log on failed");
        lr_error_message("Log on failed");
        return(0);
     }

    web_submit_data("login.do",
        "Action=http://www.****/jjh/dacms/login.do",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://www.****/jjh/dacms/login.do;jsessionid=F3678EE7651A87BE80DE3E7DE449913C",
        "Snapshot=t6.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=username", "Value=****", ENDITEM,
        "Name=password", "Value=****", ENDITEM,
        "Name=submit.x", "Value=32", ENDITEM,
        "Name=submit.y", "Value=16", ENDITEM,
        LAST);

提示結果資訊為:

Action.c(80): output:Log on failed
Action.c(81): Error: Log on failed
Ending action Action.
Error -27257: Pending web_reg_save_param/reg_find/create_html_param[_ex] request(s) detected and reset at the end of iteration number 1      [MsgId: MERR-27257]

Example 3

搜尋文本字串中“error”,If the string is found, it fails and the script execution stops.

 

    web_reg_find("Text/IC=Error", "Fail=Found", LAST );  

 

  web_url("Step", "URL=...", LAST );

 

Example 4

搜尋字串“world”,如果文本字串未被搜尋到,則指令碼執行Action spider;如果文本字串被搜尋到1次或多次,則指令碼執行Action honeybee。

 

  web_reg_find("Text=world", "SaveCount=world_count", LAST );

  web_url("Step", "URL=...", LAST );

  if (strcmp(lr_eval_string("{world_count}"), "0") == 0)

  Action spider

  else

  Action honeybee

 

loadrunner中web_reg_find使用使用方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.