Use Jmeter’s base directory

You can access these variables using Beanshell as follows:

  1. JMeter’s base dir
    import org.apache.jmeter.services.FileServer;
    
    String baseDir = FileServer.getFileServer().getBaseDir();
    vars.put("baseDir", baseDir);
    
  2. JMeter’s script location (GUI mode)
    import org.apache.jmeter.gui.GuiPackage;
    
    String testPlanFile = GuiPackage.getInstance().getTestPlanFile();
    vars.put("testPlanFile", testPlanFile);
    
  3. JMeter’s script name (non-GUI mode)
    import org.apache.jmeter.services.FileServer;
    
    String scriptName = FileServer.getFileServer().getScriptName();
    vars.put("scriptName", scriptName); 
    

If you prefer you can get the same using __Beanshell() function as

${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir())}

and it will return current base directory where it is called.

source: http://stackoverflow.com/a/28110434/1037754

Advertisements
Use Jmeter’s base directory

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s