jmeter - user defined variables and groovy












0















this is my objective:



keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).



I created this simple script in groovy:



import org.apache.jmeter.services.FileServer;
import groovy.json.JsonSlurper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

String winPath;
String macPath;
String winSlash;
String macSlash;
String userPath;
String userSlash;

if (System.properties['os.name'].toLowerCase().contains('windows')) {
winPath="C:\QA\";
winSlash="\";
vars.put("userPath",winPath.toString());
}
if (System.properties['os.name'].toLowerCase().contains('mac')) {
macPath="/Users/macUser/QA/";
macSlash="/";
vars.put("userPath",macPath.toString());
}


and add it into a "JSR223 Sampler" object under my Thread Group object



Then I've added a "User Defined Variables" object with the following var:



    Name        value
projectDir myProjectDir
rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}


Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv to FileName in "CSV Data Set Config" object, but I got this message:



2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv

2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv


as you can see it trying to read myProjectPath/AUTH.csv and then off course it get an exception..



why it doesn't "read" the variable rootPath ?



any suggestions?










share|improve this question



























    0















    this is my objective:



    keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).



    I created this simple script in groovy:



    import org.apache.jmeter.services.FileServer;
    import groovy.json.JsonSlurper;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;

    String winPath;
    String macPath;
    String winSlash;
    String macSlash;
    String userPath;
    String userSlash;

    if (System.properties['os.name'].toLowerCase().contains('windows')) {
    winPath="C:\QA\";
    winSlash="\";
    vars.put("userPath",winPath.toString());
    }
    if (System.properties['os.name'].toLowerCase().contains('mac')) {
    macPath="/Users/macUser/QA/";
    macSlash="/";
    vars.put("userPath",macPath.toString());
    }


    and add it into a "JSR223 Sampler" object under my Thread Group object



    Then I've added a "User Defined Variables" object with the following var:



        Name        value
    projectDir myProjectDir
    rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}


    Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv to FileName in "CSV Data Set Config" object, but I got this message:



    2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
    2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv

    2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
    2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
    2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
    2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
    2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
    java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv


    as you can see it trying to read myProjectPath/AUTH.csv and then off course it get an exception..



    why it doesn't "read" the variable rootPath ?



    any suggestions?










    share|improve this question

























      0












      0








      0








      this is my objective:



      keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).



      I created this simple script in groovy:



      import org.apache.jmeter.services.FileServer;
      import groovy.json.JsonSlurper;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Date;

      String winPath;
      String macPath;
      String winSlash;
      String macSlash;
      String userPath;
      String userSlash;

      if (System.properties['os.name'].toLowerCase().contains('windows')) {
      winPath="C:\QA\";
      winSlash="\";
      vars.put("userPath",winPath.toString());
      }
      if (System.properties['os.name'].toLowerCase().contains('mac')) {
      macPath="/Users/macUser/QA/";
      macSlash="/";
      vars.put("userPath",macPath.toString());
      }


      and add it into a "JSR223 Sampler" object under my Thread Group object



      Then I've added a "User Defined Variables" object with the following var:



          Name        value
      projectDir myProjectDir
      rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}


      Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv to FileName in "CSV Data Set Config" object, but I got this message:



      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv

      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
      2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
      2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
      2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
      java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv


      as you can see it trying to read myProjectPath/AUTH.csv and then off course it get an exception..



      why it doesn't "read" the variable rootPath ?



      any suggestions?










      share|improve this question














      this is my objective:



      keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).



      I created this simple script in groovy:



      import org.apache.jmeter.services.FileServer;
      import groovy.json.JsonSlurper;
      import java.text.SimpleDateFormat;
      import java.util.Calendar;
      import java.util.Date;

      String winPath;
      String macPath;
      String winSlash;
      String macSlash;
      String userPath;
      String userSlash;

      if (System.properties['os.name'].toLowerCase().contains('windows')) {
      winPath="C:\QA\";
      winSlash="\";
      vars.put("userPath",winPath.toString());
      }
      if (System.properties['os.name'].toLowerCase().contains('mac')) {
      macPath="/Users/macUser/QA/";
      macSlash="/";
      vars.put("userPath",macPath.toString());
      }


      and add it into a "JSR223 Sampler" object under my Thread Group object



      Then I've added a "User Defined Variables" object with the following var:



          Name        value
      projectDir myProjectDir
      rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}


      Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv to FileName in "CSV Data Set Config" object, but I got this message:



      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv

      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
      2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
      2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
      2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
      2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
      java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv


      as you can see it trying to read myProjectPath/AUTH.csv and then off course it get an exception..



      why it doesn't "read" the variable rootPath ?



      any suggestions?







      groovy jmeter






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 15:47









      ClaudioMClaudioM

      753919




      753919
























          2 Answers
          2






          active

          oldest

          votes


















          1
















          1. According to the User Defined Variables documentation:




            Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.





          2. Additionally be aware of JMeter Test Elements Execution Order



            0. Configuration elements
            1. Pre-Processors
            2. Timers
            3. Sampler
            4. Post-Processors (unless SampleResult is null)
            5. Assertions (unless SampleResult is null)
            6. Listeners (unless SampleResult is null)



          Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:



          ${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\QA\' } else { return '/Users/macUser/QA/' },)}


          enter image description here



          Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.






          share|improve this answer
























          • thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

            – ClaudioM
            Nov 27 '18 at 11:19



















          0














          The issue is that you try to add it to the properties and try to read it from the variables.



          Also, don't bother the or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)



          For me this works fine:



          def path;

          if (System.properties['os.name'].toLowerCase().contains('windows')) {
          path="C:\QA\";
          } else if (System.properties['os.name'].toLowerCase().contains('mac')) {
          path="/Users/macUser/QA/";
          }
          vars.put("userPath",path);
          vars.put("rootPath", path+vars.get("projectDir"));


          And to use it: log.info(vars.get("rootPath"))






          share|improve this answer
























          • ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

            – ClaudioM
            Nov 26 '18 at 9:18











          • Normally you should just use ${rootPath}.

            – Sven
            Nov 26 '18 at 10:01











          • doesn't works....

            – ClaudioM
            Nov 26 '18 at 11:35











          • ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

            – ClaudioM
            Nov 26 '18 at 13:54











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449573%2fjmeter-user-defined-variables-and-groovy%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          1. According to the User Defined Variables documentation:




            Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.





          2. Additionally be aware of JMeter Test Elements Execution Order



            0. Configuration elements
            1. Pre-Processors
            2. Timers
            3. Sampler
            4. Post-Processors (unless SampleResult is null)
            5. Assertions (unless SampleResult is null)
            6. Listeners (unless SampleResult is null)



          Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:



          ${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\QA\' } else { return '/Users/macUser/QA/' },)}


          enter image description here



          Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.






          share|improve this answer
























          • thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

            – ClaudioM
            Nov 27 '18 at 11:19
















          1
















          1. According to the User Defined Variables documentation:




            Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.





          2. Additionally be aware of JMeter Test Elements Execution Order



            0. Configuration elements
            1. Pre-Processors
            2. Timers
            3. Sampler
            4. Post-Processors (unless SampleResult is null)
            5. Assertions (unless SampleResult is null)
            6. Listeners (unless SampleResult is null)



          Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:



          ${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\QA\' } else { return '/Users/macUser/QA/' },)}


          enter image description here



          Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.






          share|improve this answer
























          • thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

            – ClaudioM
            Nov 27 '18 at 11:19














          1












          1








          1









          1. According to the User Defined Variables documentation:




            Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.





          2. Additionally be aware of JMeter Test Elements Execution Order



            0. Configuration elements
            1. Pre-Processors
            2. Timers
            3. Sampler
            4. Post-Processors (unless SampleResult is null)
            5. Assertions (unless SampleResult is null)
            6. Listeners (unless SampleResult is null)



          Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:



          ${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\QA\' } else { return '/Users/macUser/QA/' },)}


          enter image description here



          Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.






          share|improve this answer















          1. According to the User Defined Variables documentation:




            Note that all the UDV elements in a test plan - no matter where they are - are processed at the start.





          2. Additionally be aware of JMeter Test Elements Execution Order



            0. Configuration elements
            1. Pre-Processors
            2. Timers
            3. Sampler
            4. Post-Processors (unless SampleResult is null)
            5. Assertions (unless SampleResult is null)
            6. Listeners (unless SampleResult is null)



          Assuming above points your Groovy code is being executed after User Defined Variables therefore you cannot access the value. So the only way to define dynamic value depending on the operating system in the User Defined Variables is using __groovy() function directly in the Value section like:



          ${__groovy(if(System.getProperty('os.name').toLowerCase().contains('windows')){return 'C:\QA\' } else { return '/Users/macUser/QA/' },)}


          enter image description here



          Make sure to escape commas and backslashes with another backslash as in JMeter Functions comma acts as parameters separator and backslash is an escape character. Check out Apache JMeter Functions - An Introduction guide to learn more about JMeter Functions contept.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 17:33









          Dmitri TDmitri T

          71.9k33662




          71.9k33662













          • thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

            – ClaudioM
            Nov 27 '18 at 11:19



















          • thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

            – ClaudioM
            Nov 27 '18 at 11:19

















          thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

          – ClaudioM
          Nov 27 '18 at 11:19





          thank you for your suggestion @Dmitri T but I found another solution using the global variables and Bean Shell Assertion

          – ClaudioM
          Nov 27 '18 at 11:19













          0














          The issue is that you try to add it to the properties and try to read it from the variables.



          Also, don't bother the or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)



          For me this works fine:



          def path;

          if (System.properties['os.name'].toLowerCase().contains('windows')) {
          path="C:\QA\";
          } else if (System.properties['os.name'].toLowerCase().contains('mac')) {
          path="/Users/macUser/QA/";
          }
          vars.put("userPath",path);
          vars.put("rootPath", path+vars.get("projectDir"));


          And to use it: log.info(vars.get("rootPath"))






          share|improve this answer
























          • ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

            – ClaudioM
            Nov 26 '18 at 9:18











          • Normally you should just use ${rootPath}.

            – Sven
            Nov 26 '18 at 10:01











          • doesn't works....

            – ClaudioM
            Nov 26 '18 at 11:35











          • ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

            – ClaudioM
            Nov 26 '18 at 13:54
















          0














          The issue is that you try to add it to the properties and try to read it from the variables.



          Also, don't bother the or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)



          For me this works fine:



          def path;

          if (System.properties['os.name'].toLowerCase().contains('windows')) {
          path="C:\QA\";
          } else if (System.properties['os.name'].toLowerCase().contains('mac')) {
          path="/Users/macUser/QA/";
          }
          vars.put("userPath",path);
          vars.put("rootPath", path+vars.get("projectDir"));


          And to use it: log.info(vars.get("rootPath"))






          share|improve this answer
























          • ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

            – ClaudioM
            Nov 26 '18 at 9:18











          • Normally you should just use ${rootPath}.

            – Sven
            Nov 26 '18 at 10:01











          • doesn't works....

            – ClaudioM
            Nov 26 '18 at 11:35











          • ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

            – ClaudioM
            Nov 26 '18 at 13:54














          0












          0








          0







          The issue is that you try to add it to the properties and try to read it from the variables.



          Also, don't bother the or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)



          For me this works fine:



          def path;

          if (System.properties['os.name'].toLowerCase().contains('windows')) {
          path="C:\QA\";
          } else if (System.properties['os.name'].toLowerCase().contains('mac')) {
          path="/Users/macUser/QA/";
          }
          vars.put("userPath",path);
          vars.put("rootPath", path+vars.get("projectDir"));


          And to use it: log.info(vars.get("rootPath"))






          share|improve this answer













          The issue is that you try to add it to the properties and try to read it from the variables.



          Also, don't bother the or / in Java. Java handles both on every platform. (Difference between File.separator and slash in paths)



          For me this works fine:



          def path;

          if (System.properties['os.name'].toLowerCase().contains('windows')) {
          path="C:\QA\";
          } else if (System.properties['os.name'].toLowerCase().contains('mac')) {
          path="/Users/macUser/QA/";
          }
          vars.put("userPath",path);
          vars.put("rootPath", path+vars.get("projectDir"));


          And to use it: log.info(vars.get("rootPath"))







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 5:13









          SvenSven

          736515




          736515













          • ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

            – ClaudioM
            Nov 26 '18 at 9:18











          • Normally you should just use ${rootPath}.

            – Sven
            Nov 26 '18 at 10:01











          • doesn't works....

            – ClaudioM
            Nov 26 '18 at 11:35











          • ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

            – ClaudioM
            Nov 26 '18 at 13:54



















          • ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

            – ClaudioM
            Nov 26 '18 at 9:18











          • Normally you should just use ${rootPath}.

            – Sven
            Nov 26 '18 at 10:01











          • doesn't works....

            – ClaudioM
            Nov 26 '18 at 11:35











          • ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

            – ClaudioM
            Nov 26 '18 at 13:54

















          ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

          – ClaudioM
          Nov 26 '18 at 9:18





          ok @Sven thanks for your suggestion.. but how should I use the variable rootPath in "User Defined Variables" ? I tried ˋ${__groovy(vars.get("rootPath"))}ˋ and ˋvars.get("rootPath")ˋ but doesn't works

          – ClaudioM
          Nov 26 '18 at 9:18













          Normally you should just use ${rootPath}.

          – Sven
          Nov 26 '18 at 10:01





          Normally you should just use ${rootPath}.

          – Sven
          Nov 26 '18 at 10:01













          doesn't works....

          – ClaudioM
          Nov 26 '18 at 11:35





          doesn't works....

          – ClaudioM
          Nov 26 '18 at 11:35













          ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

          – ClaudioM
          Nov 26 '18 at 13:54





          ok I found the solution .. the only way to read (or better extract) the variable from groovy and read it in User Defined Variable is using the BeanShell Assertion. There you can set your global properties and then you can read it from UDV.

          – ClaudioM
          Nov 26 '18 at 13:54


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449573%2fjmeter-user-defined-variables-and-groovy%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Costa Masnaga

          Fotorealismo

          Sidney Franklin