سؤال

I was wondering if you are able to combine two user variables into one. For example I have one user variable which is defined as the location of a root folder, and a second variable defined as a location from the root, down into a subfolder, and what I'm asking if its possible to put variable 1+variable 2 = a full path way?

so for example I have one variable as:

testData.directory = ${__P(testData.directory,C:\Users\MURPHYA1\Desktop\JMeter bodies)}
testData.testCases = ${__P(testData.testCases,\JMeter Basket body files)    

and what i want to produce is: C:\Users\MURPHYA1\Desktop\JMeter bodies\JMeter Basket body files

Is this possible?

UPDATE

I now have the following config and quite a few test variables just for testing: JMeter Config

هل كانت مفيدة؟

المحلول

Add a second "User Defined Variables" element after yours. There every variable will be replaced by the values defined in your first element.

- User Defined Variables
- - test1 = a/
- - test2 = b
- User Defined Variables 2
- - test3 = ${test1}${test2} 

نصائح أخرى

try this

${__V(${keyword1}${keyword2})}

I was NOT able to combine 2 variables into one in jmeter. I tried several approaches, but ended up using the two variables side by side in the rest of the test plan. :-(

You can create a User Defined Variable with name test and value:

  • ${testData.directory}${testData.testCases}

And then use : ${__evalVar(test)} in place

Also it is better to use / instead of \ for path properties and variables as they will work both in Linux and Windows.

For example you have 2 variables:

  1. A variable from Regular Extractor: ${employeeID}
  2. Second variable is a simple Variable defined in User Defined Variables: Test1 = ${__Random(14,25,)}

  3. Now we concatinate/combine this 2 variables, it will look like this:

    ${__V(employeeID_${Test1})} ${employeeID} + $ {Test1} = ${__V(employeeID_${Test1})}

__V function

BeanShell Prozessor:

String var1 = vars.get("var1");
String var2 = vars.get("var2");
vars.put("var3", var1+"."+var2);

Use in BeanShell PostProcessor:

vars.put ("folder", vars.get("testData.directory") + vars.get("testData.testCases"))

So once you have: var testData.directory = ${__P(testData.directory,"C:\Users\MURPHYA1\Desktop\JMeter bodies")} var testData.testCases = ${__P(testData.testCases,"\JMeter Basket body files")

You will end up with concatenating the two variables into

folder = "C:\Users\MURPHYA1\Desktop\JMeter bodies\JMeter Basket body files"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top