我需要在 Loadrunner VUGen 中获取整个响应正文。我试试
web_set_max_html_param_len("60000");
web_reg_save_param_ex(
"ParamName=js_top",
"LB=",
"RB=",
SEARCH_FILTERS,
"Scope=Body",
LAST);
web_url("categories",
"URL=https://advantageonlineshopping.com/catalog/api/v1/categories",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=https://advantageonlineshopping.com/",
"Snapshot=t20.inf",
"Mode=HTML",
LAST);
但出现错误: Action.c(147):错误-26377:找不到请求的参数“js_top”的匹配项。在响应中未找到指定的边界,或者匹配的文本比当前最大 html 参数大小 60000 字节长。响应的总长度为 4477 字节。您可以使用“web_set_max_html_param_len”来增加最大参数大小。 [消息 ID:MERR-26377]
尝试使用下面的内容,如果您遇到任何问题,请告诉我。
web_set_max_html_param_len("9999999");
web_reg_save_param("c_fullresponse", "LB=", "RB=", LAST);
web_url("categories",
"URL=https://advantageonlineshopping.com/catalog/api/v1/categories",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=https://advantageonlineshopping.com/",
"Snapshot=t20.inf",
"Mode=HTML",
LAST);
如果仍然出现错误,请尝试启用日志。从运行时设置中的日志打开服务器跟踪。 启用日志后您将收到响应。根据该数据,您可以决定需要什么 LB 或 RB,以捕获完整的响应。
该代码对我有用:
web_set_max_html_param_len("9999999");
web_reg_save_param_json(
"ParamName=userId", // Specify the parameter name to store the captured value
"QueryString=$.data.accessToken", // Specify the JSONPath expression to extract the value
//"Ordinal=1", // Specify the occurrence of the value if there are multiple matches
LAST);
web_custom_request("login_2",
"URL=https://reconstream-int.timestreamgroup.com/api/users/login",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=https://reconstream-int.timestreamgroup.com/login",
"Snapshot=t334.inf",
"Mode=HTML",
"EncType=application/json",
"Body={\"data\":{\"username\":\"[email protected]\",\"password\":\"@2023\"}}",
LAST);
web_set_user("reconstream-int.timestreamgroup.com\\[email protected]", "@2023", "reconstream-int.timestreamgroup.com");
lr_think_time(60);
/*web_reg_save_param("data",
"LB/IC={\"data\": {",
"RB/IC=\"checker\": null}",
LAST);*/
//lr_output_message("Response Body: %s", lr_eval_string("{data}"));
lr_output_message("Response Body: %s", lr_eval_string("{userId}"));