在jMeter的值字段中使用变量 [英] Using variable in a value field in jMeter

查看:449
本文介绍了在jMeter的值字段中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我添加了一个用户定义变量元素

  1. I've added a User Defined Variables element

  • 然后创建一个值为$ 123456的变量$ {Parameter}并将其传递给GET请求.
  • 创建了第二个变量$ {Response},其值为无效代码123456"

我添加了一个Response Assertion元素

I've added a Response Assertion element

  • 将$ {Response}变量添加到响应声明"中

当我这样发送请求时,一切都很好.但是,如果我在value字段中添加第二个变量,则会返回断言错误.

When I send the request like this, everything is fine. But if I add the second variable in the value field, then an Assertion error is returned.

我想要做的是将一个变量添加到一个已经存在的变量的value字段中: 例如将$ {Response}变量的值设置为无效代码$ {Parameter}"

What I'm trying to do is to add a variable to the value field of an already existing variable: e.g. Set the Value of the ${Response} variable as "Invalid code ${Parameter}"

我如何在jmeter中实现这一目标?

How can I achieve this in jmeter?

推荐答案

为什么不必要地使事情变得复杂!

Why are you unnecessarily making the things complex!

您可以直接在Response Assertion中使用要声明的值.

You can directly use the value you want to assert in the Response Assertion.

保持如下:

Invalid code ${Parameter}

在这里,首先评估$ {Parameter}值,然后根据响应进行检查.

Here, ${Parameter} value be evaluated first and checked against the response.

以防万一,如果要使用JMeter变量作为另一个JMeter变量的值,请使用以下内容,并使用${__evalVar()}:

Just incase, if you want to use JMeter variable as value to another JMeter variable, use as follows, using ${__evalVar()}:

Invalid code ${__evalVar(Parameter)}

注意:观察到,如果您在同一UDV中定义两个变量,则Parameter值为空.因此,添加两个UDV,并在第一个UDV中定义Parameter,在第二个UDV中将Response定义为上面的值.

Note: observed that if you define both the variables in the same UDV, Parameter value is empty. So, add two UDVs and define Parameter in the first UDV and Response in the second UDV with above value.

这篇关于在jMeter的值字段中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆