• 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

  • 相关阅读:
    C#中的异常处理
    How to: Create a Windows Communication Foundation Client
    王立平--result += "{";
    Gradle增量学习建筑
    android 当屏幕截图,你如何改变屏幕内容,他们俩bitmap将合并的图像被一起显示
    惊人go语言(image网站开发)
    树莓派的演奏音符3 -- LCD1602显示文章
    Linux解析内核源代码——传输控制块诞生
    Preemption Context Switches 和 Synchronization Context Switches
    folat i = 0.1; 警告
  • 原文地址:https://www.cnblogs.com/memory0406/p/6256614.html
Copyright © 2020-2023  润新知