本文以系统登录过程为实例,讲解如何参数化、设置参数属性和导入数据
首先录制到登录过程的脚本并添加了检查点,如下:
web_custom_request("gettoken",
"URL=http://10.16.56.250/ImageSky.GISCase.SZ.SCD/api/v1/users/gettoken",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://10.16.56.250/ImageSky.GISCase.SZ.SCD/dist/",
"Snapshot=t1.inf",
"Mode=HTTP",
"EncType=application/json;charset=utf-8",
"Body={\"username\":\"test\",\"password\":\"123456\"}",
LAST);
web_reg_find("Fail=NotFound",
"Search=All",
"SaveCount=login_count",
"Text=\"username\":\"{checkpoint}\"",
LAST);
web_custom_request("login",
"URL=http://10.16.56.250/ImageSky.GISCase.SZ.SCD/api/v1/users/login",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://10.16.56.250/ImageSky.GISCase.SZ.SCD/dist/",
"Snapshot=t2.inf",
"Mode=HTTP",
"EncType=application/json;charset=utf-8",
"Body={\"token\":\"{gettoken}\"}",
LAST);
if(strcmp(lr_eval_string("{login_count}"),"0")==1)
//if(strcmp(lr_eval_string("{Count}"))>0)
lr_log_message("登陆成功!");
else
lr_log_message("登陆失败!");
选中要参数化的常量,如上面的红色字体,点击鼠标右键,选择replace with a parameter,对用户名和密码进行参数化