seanrco
seanrco

Reputation: 1079

Call user defined variable in another variable

Is it possible to call a user defined variable within another user defined variable? For example, in the screenshot below I would like to call the variable 'CmsVersion' value in 'ResultsPath'. Right now it is outputting ${CmsVersion} as the folder name and not the variable value.

User Defined Variables

Upvotes: 1

Views: 1200

Answers (2)

Rahul Jadhav
Rahul Jadhav

Reputation: 463

Variables declared in the same User defined variables config element cannot be reused in the same element. You can move it to Test Plan level as per screenshot below Variable declared at test plan level

In your case you will need to do another special handling because you are dealing with a windows folder path. the \ is escape character in JAVA. When you say \${CmsVersion} JAVA is treating \$ as an escape sequence.

enter image description here

I have declared 2 variables CmsVersion correlated within the same config element and CmsVersion1 correlated from Test Plan variable.

Result is as below in Debug Sampler enter image description here

Upvotes: 2

Dmitri T
Dmitri T

Reputation: 168237

You cannot, at least not within the bounds of a single User Defined Variables configuration element.

It is possible if you add another User Defined Variables below your original one, this way you will be able to reference the variables define in the above configuration element in the one(s) which is (are) below:

Demo:

enter image description here

More information: Using User Defined Variables

Upvotes: 5

Related Questions