loadrunner中web_reg_find使用使用方法


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM