方法1 通过变量传递参数:
第一个脚本:
HTTP Request_新建出差申请单_登录,关联出参数token、companyId、userId、userName
1.添加后置处理器:BeanShell PostProcessor
2.参数parameters:${token}
脚本scripts:
${__setProperty(token1,${token},)};
${__setProperty(companyId1,${companyId},)};
${__setProperty(userId1,${userId},)};
${__setProperty(userName1,${userName},)};
3.第2和脚本添加前置处理器
script脚本:
String a1=props.get("token1");
vars.put("token2",a1);
String b1=props.get("companyId1");
vars.put("companyId2",b1);
String c1=props.get("userId1");
vars.put("userId2",c1);
String d1=props.get("userName1");
vars.put("userName2",d1);
4.脚本中用${}
方法2: 全局变量:
BeanShell PostProcessor:
脚本
String newtoken=bsh.args[0];
print(newtoken);
${__setProperty(newtoken,${token},)};
String newcompanyId=bsh.args[1];
print(newcompanyId);
${__setProperty(newcompanyId,${companyId},)};
String newuserId=bsh.args[2];
print(newuserId);
${__setProperty(newuserId,${userId},)};
String newuserName=bsh.args[3];
print(newuserName);
${__setProperty(newuserName,${userName},)};