1
我有两个提取的值(count和count1) - >这些应该是整数。我需要减去(count1 - count = difference)并使用webtest循环中的差异(删除生成的组)。VS Webtest:如何在Webtest循环计数中使用请求中提取的值?
如何将此结果传递给Webtest循环(迭代)计数?
http://hmp.me/pz0 http://hmp.me/pz2
我有两个提取的值(count和count1) - >这些应该是整数。我需要减去(count1 - count = difference)并使用webtest循环中的差异(删除生成的组)。VS Webtest:如何在Webtest循环计数中使用请求中提取的值?
如何将此结果传递给Webtest循环(迭代)计数?
http://hmp.me/pz0 http://hmp.me/pz2
您可以创建一个Web测试请求插件,给它三个参数(即属性)两个是count1
和count2
上下文参数。该插件执行减法并将结果存储到第三个上下文参数中(通过第三个属性命名)。然后在循环条件中使用第三个上下文参数中的值。
输入上下文参数将包含需要转换为整数(或浮点数或任何您的应用程序需要)的字符串。保存之前,结果需要转换回字符串。
该插件可能如下。注意:未编译或测试。注意:同样的代码也可以在PreRequest
或PreRequestDataBinding
插件中完成。
public class SubtractContextParameters : WebTestRequestPlugin
{
public string LeftHandNumberCP { get; set; }
public string RightHandnumberCP { get; set; }
public string ResultCP { get; set; }
public override void PostRequest(object sender, PostRequestEventArgs e)
{
int left = int.Parse(e.WebTest.Context[LeftHandNumberCP].ToString());
int right = int.Parse(e.WebTest.Context[RightHandnumberCP].ToString());
int result = left - right;
e.WebTest.Context[ResultCP] = result.ToString();
}
}
传递给ResultCP
属性的名称然后可以在Web测试循环中的NumberComparison
条件下使用。