是否可以使用lr_save_string进行连接?
排序,下一步和篮子,bookIDs_array都是正确的赋值。
代码
lr_save_string(lr_eval_string("sortoption={sortoption}&next={next}&basket={basket}"), "BodyString");
for (i=1; i<=lr_paramarr_len("BookIDS_array"); i++) {
lr_save_string(lr_paramarr_idx("BookIDS_array", i), "BookID");
lr_save_string(lr_eval_string("{BodyString}&bookId%5B%5D%3D{BookID}"), "BodyString");
}
lr_output_message("Value: %s", lr_eval_string("{BodyString}"));然而,上面的内容似乎只是将下面的内容分配给BodyString
sortoption={sortoption}&next={next}&basket={basket}
发布于 2017-01-12 13:32:22
对于LoadRunner中的级联示例,您可能需要考虑另一个线程。
How to change input soap request as per test data in loadrunner?
发布于 2018-11-23 03:43:35
我看了一下XML链接,它与我想要做的非常相似,但是如果有值,我需要更新一些json。我对这个问题的看法如下:
//Define the object to store.
char ifPhoneThenAdd[100];
...
...
...
//Capture the full part of the address information of the first entry including city, phone, etc. - In my scenario, all I need is the first one from the json response..
web_reg_save_param_json("ParamName=AddressData","QueryString=$.Addresses","SelectAll=No",SEARCH_FILTERS,"Scope=Body",LAST);
...
...
...
web_rest("......",
"URL={App_URL}/details/{userID}",
"Method=GET",
"Snapshot=t999990.inf",
LAST);
...
...
...
//Some explanation of the json output:
//A sample of the json output would look something like this (from the output tab):
//Saving Parameter "AddressData" = [{"Id":"xxxxxxxxxxx","city":"Calgary","street":"123 Santas Workshop","postalCode":"H0H 0H0","country":"CA","region":"AB","email":"baba@oriley.com","phone":"403xxxxxxx"}]"
//Without the phone, it would be:
//[{"Id":"xxxxxxxxxxx","city":"Calgary","street":"123 Santas Workshop","postalCode":"H0H 0H0","country":"CA","region":"AB","email":"baba@oriley.com"}]"
//This part changes the body in case there is a phone number and does not include phone number if there is none in the reply.
sprintf(ifPhoneThenAdd,"");
if (strstr(lr_eval_string("{AddressData}"), "\"phone\"") != NULL)
{
lr_eval_json("Buffer={AddressData}", "JsonObject=json_obj", LAST);
lr_json_get_values("JsonObject=json_obj", "ValueParam=AddressWithPhoneNumber", "QueryString=$..phone", "SelectAll=No", LAST);
sprintf(ifPhoneThenAdd,"%s%s%s",",\r\n\"phoneNumber\":\"",lr_eval_string("{AddressWithPhoneNumber}"),"\"");
}
else
{
//Doesn't make the script fail, but will send an error message.
lr_error_message("No phone number for ID: %s", lr_eval_string("{userID}"));
}
lr_save_string(ifPhoneThenAdd, "ifPhoneThenAddString");
//If there is no phone, then the string ifPhoneThenAddString will be empty and nothing but the empty string will be added to the json output.
//If there is a phone, then the body will get appended with the right json output with the phone number.
...
...
...
web_rest("......",
"URL={App_URL}/updateSomethingNeedingAddress/{userID}",
"Method=POST",
"EncType=raw",
"Snapshot=t999991.inf",
"Body={\r\n"
"\"Id\":\"{userID}\",\r\n"
"\"firstName\":\"{userFirstname}\",\r\n"
"\"lastName\":\"{userLastname}\",\r\n"
"\"streetName\":\"{userStreetName}\",\r\n"
"\"city\":\"{userCity}\",\r\n"
"\"province\":\"{userProvince}\",\r\n"
//This part will add the phone part if there is one after the postalCode. If no phone, the postalCode will be the last part of the json.
"\"postalCode\":\"{userPostalCode}\"{ifPhoneThenAddString}\r\n"
"}",
HEADERS,
"Name=Content-Type", "Value=application/json", ENDHEADER,
LAST);
...
...
...
return 0;https://stackoverflow.com/questions/41613723
复制相似问题