我正在研究Loadrunner winsocket协议并尝试计算lrs_save_param或lrs_save_searched_string函数中是否有选项将其标记为警告,或者如果收到的缓冲区为空则找不到。
如果没有响应,是否可以将该事务标记为失败并继续下一次迭代?
使用以下代码,如果没有响应,则用户失败并退出测试。
[
{
"ref": "000051",
"name": "DURA GREEN",
"desc": "DURA GREEN 30 TO 0",
"price": "29.000",
"skus": [
{
"barcode": "000051046008",
"color": "KHAKI R",
"size": "42",
"price": "29.00"
},
{
"barcode": "000051046009",
"color": "KHAK",
"size": "44",
"price": "29.00"
}
]
},
{
"ref": "000072",
"name": "WHITE DURA",
"desc": "WHITE DURABLE 30 - 54",
"price": "29.000",
"skus": [
{
"barcode": "000072043010",
"color": "WHITE L",
"size": "48",
"price": "29.00"
},
{
"barcode": "000072043011",
"color": "WHITE L",
"size": "50",
"price": "29.00"
}
]
},
{
"ref": "000078",
"name": "EBAY KARLSON",
"desc": "SMART WHITE TROUSERS WITH PRIE",
"price": "34.000",
"skus": [
{
"barcode": "000078042002",
"color": "WHITE R",
"size": "30",
"price": "34.00"
}
]
},
{
"ref": "000053",
"name": "DURA BLACK",
"desc": "DURA BLACK WAIST 30 TO 54",
"price": "19.000",
"skus": [
{
"barcode": "000053038004",
"color": "BLACK S",
"size": "36",
"price": "19.00"
}
]
},
{
"ref": "000080",
"name": "DURA WHITE EBY",
"desc": "WHITE DURABLE 30 - 44",
"price": "34.000",
"skus": [
{
"barcode": "000080042007",
"color": "WHITE R",
"size": "51",
"price": "37.00"
}
]
},
{
"ref": "000025",
"name": "DURABLEPRESS",
"desc": "DURABLEPRESS 30 TO 50 WAIST",
"price": "19.000",
"skus": [
{
"barcode": "000025022002",
"color": "NAVY S",
"size": "30",
"price": "19.00"
},
{
"barcode": "000025022003",
"color": "NAVY S",
"size": "30",
"price": "19.00"
}
]
}
]
答案 0 :(得分:1)
不幸的是,你无法逃避错误:如果 lrs_receive()无法收到回复或 lrs_save_searched_string()找不到搜索到的字符串,那么你的脚本将会以错误结果结束。这些功能中没有这样的选项可以使它们沉默错误。但是,您可以强制LoadRunner忽略错误并使用错误时继续模式继续执行脚本。有两种使用方法:
你可以这样做:
lrs_create_socket("socket9", "TCP", "RemoteHost={dpHostName}:8800", LrsLastArg);
lrs_send("socket9", "buf5", LrsLastArg);
// start of code with possible failures
lr_continue_on_error(1);
if (lrs_receive("socket9", "buf6", LrsLastArg) != 0)
{
lr_output_message("could not receive the response!");
}
if (lrs_save_searched_string("socket9", LRS_LAST_RECEIVED, "CorrelationParameter",
"LB/BIN=AUTH", "RB/BIN=,,,,,,,,,,,,,", 1, 0, -1) == LRS_SAVE_PARAM_ERR)
{
lr_output_message("parameter not found!");
}
// end of code with possible failures
lr_continue_on_error(0);
检查 [LR目录] \ include \ lrs_err.h 以获取其他错误代码。