Loadrunner 2021 入门
文章目录
脚本不会写不求人,我有“帮助中心”;里面有语法介绍和使用示例代码。
一、Virtual User Generator
1.快捷键
快捷键 | 描述 |
---|---|
ctrl+space | 代码补全 |
ctrl+alt+b | 步骤工具箱 |
Action()
{
/*Possible OAUTH authorization was detected. It is recommended to correlate the authorization parameters.*/
web_set_sockets_option("SSL_VERSION", "AUTO");
web_add_header("Origin",
"http://192.168.63.20");
web_reg_save_param_json(
"ParamName=access_token",
"QueryString=$data.token.access_token",
SEARCH_FILTERS,
"Scope=Body",
"LAST");
web_reg_save_param_json(
"ParamName=token",
"QueryString=$data.token",
SEARCH_FILTERS,
"Scope=Body",
"LAST");
web_custom_request("login",
"URL=http://192.168.63.20/prod-api/auth/login",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t1.inf",
"Mode=HTML",
"EncType=application/json;charset=UTF-8",
"Body={\"username\":\"admin\",\"password\":\"123456\"}",
LAST);
web_add_cookie("Admin-Token={token}; DOMAIN=192.168.63.20");
lr_log_message("user token is:%s",lr_eval_string("{token}"));
web_add_auto_header("Authorization", "Bearer {access_token}");
web_url("info",
"URL=http://192.168.63.20/prod-api/auth/info",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);
web_add_header("Origin",
"http://192.168.63.20");
web_custom_request("10",
"URL=http://192.168.63.20/prod-api/eventTask/pageEventTask/1/10",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t4.inf",
"Mode=HTML",
"EncType=application/json;charset=UTF-8",
"Body={\"page\":1,\"limit\":10}",
LAST);
web_url("getTriggerStateCount",
"URL=http://192.168.63.20/prod-api/eventTask/getTriggerStateCount",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t5.inf",
"Mode=HTML",
LAST);
web_url("list",
"URL=http://192.168.63.20/prod-api/system/list",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);
web_url("findDatabaseMun",
"URL=http://192.168.63.20/prod-api/database/findDatabaseMun",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t7.inf",
"Mode=HTML",
LAST);
web_url("findInterfaceMun",
"URL=http://192.168.63.20/prod-api/interface/findInterfaceMun",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t8.inf",
"Mode=HTML",
LAST);
web_url("findTopicUse",
"URL=http://192.168.63.20/prod-api/subscribe/findTopicUse",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);
web_url("findConsumerUse",
"URL=http://192.168.63.20/prod-api/subscribe/findConsumerUse",
"Resource=0",
"RecContentType=application/json",
"Referer=http://192.168.63.20/",
"Snapshot=t10.inf",
"Mode=HTML",
LAST);
return 0;
}
二、Controller
三、Analysis
四、运行jmeter脚本
九、遇到问题
1.录制脚本时 打不开网页或者打开网页慢