51Testing软件测试论坛
标题:
LR调用接口时参数好像传不上去,求解救
[打印本页]
作者:
386749983
时间:
2015-6-12 15:09
标题:
LR调用接口时参数好像传不上去,求解救
这里初学,想要试试接口测试,对着教程写了一段代码
char
str
[
1000
];
strcpy
(
str
,
"mac=38:BC:1A:0F:2F:A1&phoneNum=12345678987"
);
web_custom_request
(
"/account-server/require-icode"
,
"Url=http://192.168.1.210:9680/account-server/require-icode"
,
"Method=Get"
,
"RecContentType=application/json"
,
"Mode=HTTP"
,
"Body=str"
,
LAST
);
回放时提示成功,但是并没有返回值。有两条警告:
警告 -26000: Request body (lengths) is not empty for HTTP methods, for URL is "hp://192.168.1.210:9680/accounted/requirements" (Internal Idea) [Did: Warned]
警告 -26631: 对于“[url]http://192.168.1.210:9680/accounted/requirements
状态代码=400 (Bad Request) [Did: Warned][/url]
后来把代码改了一下 改成了下面这样
web_custom_request("/account-server/require-icode",
"URL=http://192.168.1.210:9680/account-server/require-icode",
"Method=Get",
"RecContentType=application/octet-stream",
"Body=jsonStr={\"mac\":\"38:BC:1A:0F:2F:A1\",\"phoneNum\":\"12345678987\"}\n",
LAST);
还是回放时提示成功,但是并没有返回值。同样的警告信息
我觉得是参数没有传过去
后来试了另外一种方法成功了
web_submit_data("insert",
"Action=http://192.168.1.210:9680/account-server/require-icode ",
"Method=GET",
/* "Referer=http://192.168.1.210:9680/account-server/require-icode ", */
"Mode=HTML",
ITEMDATA,
"Name=mac","Value=38:BC:1A:0F:2F:A1",ENDITEM,
"Name=phoneNum","Value=12345678987",ENDITEM,
LAST);
求大家帮我看看 前面的代码到底是哪里有问题 为什么没有返回值
作者:
qwe123zml
时间:
2015-6-12 15:50
你说的教程是哪本书?
作者:
386749983
时间:
2015-6-12 18:04
qwe123zml 发表于 2015-6-12 15:50
你说的教程是哪本书?
不是书 就是网上看的教程
http://www.blogjava.net/qileilove/archive/2012/05/31/379631.html
这个帖子
作者:
beautifulycx
时间:
2015-6-30 22:40
mk一下
作者:
saharaqs
时间:
2015-7-1 09:25
第一种,变量str不能直接使用,需要把变量转为参数再调用:
lr_save_string("mac=38:BC:1A:0F:2F:A1&phoneNum=12345678987","str");
web_custom_request("/account-server/require-icode",
"Url=http://192.168.1.210:9680/account-server/require-icode",
"Method=Get",
"RecContentType=application/json",
"Mode=HTTP",
"Body={str}",
LAST);
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2