Access to JMeter script path

Richard Szalay picture Richard Szalay · Feb 7, 2012 · Viewed 15.9k times · Source

Is there a way of accessing the current script's absolute physical path via a variable/property? There doesn't appear to be anything listed via a Debug Sampler.

It's incredibly annoying that actions like loading CSV files and JMX Includes uses the current working directory as its relative path.

Answer

madhatter160 picture madhatter160 · Mar 13, 2013

I used the answer provided by haridsv. It worked great except that I needed to put the directory to the JMX file in a variable. I made a "User Defined Variables" component and used BeanShell in the variable's "Value" field like this:

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

The first BeanShell section calls the Java class that gets the directory in question. The second appends a file separator to the path, which is of course optional.