• 编写前程贷投标loadrunner脚本及总结


    1、完成前程贷的(登录,投标)

    2、所有的返回信息都用关联函数(web_reg_save_param_ex)进行关联

    3、对返回信息用(strcmp)函数进行if判断

    4、总结(web_reg_save_param和web_reg_save_param_ex)区别

    Action()
    {
        
        
        web_reg_save_param_ex(
            "ParamName=success01",
            "LB=class="success">",
            "RB=</p>",
            "Ordinal=1",
            SEARCH_FILTERS,
            "Scope=ALL",
            LAST);
    //    
        
        //登录
        lr_start_transaction("登录");
        
        web_submit_data("web_submit_data",
            "Action=http://120.78.128.25:8765/Frontend/Index/login",
            "Method=POST",
            "TargetFrame=",
            "Referer=http://120.78.128.25:8765/Index/login.html",
            ITEMDATA,
            "Name=phone", "Value=13825161923", ENDITEM,
            "Name=password", "Value=lemon123", ENDITEM,
            "Name=remember_me", "Value=1", ENDITEM,
            LAST);
        lr_end_transaction("登录", LR_AUTO);

        lr_error_message("cg---:%s",lr_eval_string("{success01}"));
        

    //    //获取投标id
        web_reg_save_param_ex(
            "ParamName=get_id",
            "LB=href="/loan/loan_detail/Id/",
            "RB=.html",
            "Ordinal=1",
            SEARCH_FILTERS,
            "Scope=ALL",
            LAST);
    //获取账号名    
    web_reg_save_param_ex(
            "ParamName=get_username",
            "LB=>我的帐户[",
            "RB=]</a>",
            "Ordinal=1",
            SEARCH_FILTERS,
            "Scope=ALL",
            LAST);
    //首页
        web_url("web_url",
            "URL=http://120.78.128.25:8765/Index/index.html",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTML",
            LAST);

    lr_error_message("投标id:%s",lr_eval_string("{get_id}"));
    lr_error_message("投标用户:%s",lr_eval_string("{get_username}"));
        
        //获取token
        web_reg_save_param_ex(
            "ParamName=get_token",
            "LB=data-token="",
            "RB==" data-id=",
            "Ordinal=1",
            SEARCH_FILTERS,
            "Scope=ALL",
            LAST);

        //产生token
     web_url("web_url",
            "URL=http://120.78.128.25:8765/loan/loan_detail/Id/{get_id}.html",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTML",
            LAST); 
        lr_error_message("投标token:%s",lr_eval_string("{get_token}"));
        
        //获取投标返回值
        web_reg_save_param_ex(
            "ParamName=get_code",
            "LB={"state":",
            "RB=,"msg":",
            "Ordinal=1",
            SEARCH_FILTERS,
            "Scope=ALL",
            LAST);
        lr_start_transaction("投标");
        web_submit_data("web_submit_data",
            "Action=http://120.78.128.25:8765/Invest/invest",
            "Method=POST",
            "TargetFrame=",
            "Referer=",
            "Mode=HTML",
            ITEMDATA,
            "Name=id", "Value={get_id}", ENDITEM,
            "Name=val", "Value=100", ENDITEM,
            "Name=token", "Value={get_token}", ENDITEM,
            "Name=rewardValue", "Value=0", ENDITEM,
            LAST);


         //对strcmp函数的运用
        if(strcmp(lr_eval_string("{get_code}"),"1")==0)
        {
            lr_end_transaction("投标", LR_PASS);
            lr_error_message("投标成功!:%s,用户名:%s,投标id:%s",lr_eval_string("{get_code}"),lr_eval_string("{get_username}"),lr_eval_string("{get_id}")); //每个占位符与后面每个参数对应
        }
        else{
            lr_end_transaction("投标", LR_FAIL);
            lr_error_message("投标失败!!:%s",lr_eval_string("{get_code}"));
        }

        return 0;
    }

    5、预习(lr_save_string,web_custom_request)函数和参数化

      1)int lr_save_string (const char *param_value, const char *param_name);

      函数目的:将param_value值保存到param_name变量中

      参数介绍:param_value:要保存的值

      param_name: 变量名称

      例子:

      lr_save_string("10","test"); //将常量10保存为参数test

      lr_output_message(lr_eval_string("{test}"));  //获取并输出参数的当前值  

      执行结果:10

      2)

    Int web_custom_request (const char *RequestName, <List of Attributes>, [EXTRARES, <List of Resource Attributes>,] LAST );

    返回值

    返回 LR_PASS(0)代表成功,LR_FAIL(1)代表失败。参数:

    RequestName:步骤的名称,VuGen 中树形视图中显示的名称。

    List of Attribute:支持的属性有以下几种:

    URL:页面地址。

    Method :页面的提交方式,POST 或 GET。

    TargetFrame:包含当前链接或资源的 frame 的名称。参见 List of Attributes

    的同名参数。

    EncType:编码类型。

    RecContentType:响应头的内容类型。参见 List of Attributes 的同名参数。

    Referer:参见 List of Attributes 的同名参数。

    Body:请求体。参见 List of Attributes 的同名参数。

    RAW BODY:参见 List of Attributes 的同名参数。

    BodyFilePath:作为请求体传送的文件的路径。它不能与下面的属性一起使用: Body,或者其他 Body 属性或 Raw Body 属性包括 BodyBinary,BodyUnicode,

    RAW_BODY_START 或 Binary=1。

    Resource、ResourceByteLimit、Snapshot、Mode:参见 List of Attributes

    的同名参数。

    ExtraResBaseDir:参见 List of Attributes 的同名参数。

    UserAgent:用户代理,它是一个 HTTP 头的名字,用来标识应用程序,通常是浏览器,它呈现的是用户和服务器的交互。

  • 相关阅读:
    随笔12 java反射机制
    随笔11 J2EE中常用的名词解释
    随笔⑩ java中的基本数据类型的基础知识
    随笔⑨ java中的变量 --- 类变量(静态变量),final变量,成员变量,局部变量 java中的方法 --- 类方法(静态方法),final方法,成员方法(实例方法),构造方法
    随笔⑧ java中的存根类 --- Stub
    随笔⑦ Java中的比较 ==,equals以及精度对比较的影响
    随笔⑥ 关于线程 --- 线程操作的主要方法
    Jupyter notebook and Octave kernel installation
    [C7] Andrew Ng
    [C6] Andrew Ng
  • 原文地址:https://www.cnblogs.com/shonblog/p/10679392.html
Copyright © 2020-2023  润新知