• lr12脚本参数化


    1、注册、登录、获取商品列表lr脚本

    Action()
    {   
        lr_save_string("192.168.46.129:8080","IP");
        注册
        web_reg_save_param_ex(
            "ParamName=注册结果",
            "LB={"code":",
            "RB=,"msg":",
            "Ordinal=1",
            SEARCH_FILTERS,
            LAST);

        
        lr_start_transaction("注册");

        web_custom_request("注册",
            "URL=http://{IP}/mobile/api/user/register",
            "Method=POST",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTTP",
            "EncType=application/json;charset=utf-8",
            "Body={"mobile":"{mobile}","password":"{username}","code":"3367","platform":"windows","username":"","sex":1,"age":20,"email":""}",
            LAST);
        
        
        if(strcmp(lr_eval_string("{注册结果}"),"0")==0)
        {
        lr_end_transaction("注册", LR_PASS);
        lr_output_message("注册成功,返回响应码%s",lr_eval_string("{注册结果}"));
        }
        else
        {
        lr_end_transaction("注册", LR_FAIL);
        lr_error_message("注册失败,返回响应码%s",lr_eval_string("{注册结果}"));
        }
        
        
        //登录
        web_reg_save_param_ex(
            "ParamName=登录结果",
            "LB={"code":",
            "RB=,"msg":",
            "Ordinal=1",
            SEARCH_FILTERS,
            LAST);

        lr_start_transaction("登录");

        web_custom_request("登录",
            "URL=http://{IP}/mobile/api/user/login",
            "Method=POST",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTTP",
            "EncType=application/json;charset=utf-8",
            "Body={"mobile":"{mobile}","password":"{password}"}",
            LAST);
        lr_output_message("用户名:%s",lr_eval_string("{mobile}"));
        lr_output_message("密码:%s",lr_eval_string("{password}"));

           if(strcmp(lr_eval_string("{登录结果}"),"0")==0)
        {
        lr_end_transaction("登录", LR_PASS);
        lr_output_message("登录成功,返回响应码%s",lr_eval_string("{登录结果}"));
        }
        else
        {
        lr_end_transaction("登录", LR_FAIL);
        lr_error_message("登录失败,返回响应码%s",lr_eval_string("{登录结果}"));
        }

       //获取商品列表
        web_reg_save_param_ex(
            "ParamName=获取商品列表结果",
            "LB={"code":",
            "RB=,"msg":",
            "Ordinal=1",
            SEARCH_FILTERS,
            LAST);

        lr_start_transaction("获取商品列表");

        web_custom_request("商品列表",
            "URL=http://{IP}/mobile/api/goods/gettypes",
            "Method=GET",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Mode=HTTP",
            "EncType=application/json;charset=utf-8",
            "Body={"type":1,"offset":"","size":""}",
            LAST);

        if(strcmp(lr_eval_string("{获取商品列表结果}"),"0")==0)
        {
        lr_end_transaction("获取商品列表", LR_PASS);
        lr_output_message("获取商品列表成功,返回响应码%s",lr_eval_string("{获取商品列表结果}"));
        }
        else
        {
        lr_end_transaction("获取商品列表", LR_FAIL);
        lr_error_message("获取商品列表失败,返回响应码%s",lr_eval_string("{获取商品列表结果}"));
        }


        
        return 0;
    }

    2、文件参数化、数据库参数化、其它参数化

    3、参数化九种取值方式

  • 相关阅读:
    Linux
    Monkey命令
    ADB命令
    DOS命令
    列表
    函数
    文件读写及实操项目
    Selenium2自动化——初体验
    新开淘宝店怎么提升信誉,是不是真的要刷钻?
    JSFL:导入根文件夹将所有图片添加库链接导出swf
  • 原文地址:https://www.cnblogs.com/nikeke/p/10703811.html
Copyright © 2020-2023  润新知