Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access to JMeter script path

Tags:

java

jmeter

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.

like image 582
Richard Szalay Avatar asked Feb 07 '12 15:02

Richard Szalay


People also ask

Which directory is the part of JMeter directory structure?

/lib Folder: The lib folder contains all the executable jar files which are required for JMeter functioning. These files are as same as jar file of java. /lib folder contains two subfolders /ext and /JUnit. The /ext or extension sub-folders are useful when you add an external plugin in the JMeter.

How do I open a JMX file in JMeter?

jmx file in Windows 10 operating system. Right click on valid JMeter test plan, go to Open with > Choose another app as shown below. Upon clicking on Open, JMeter will launch and open the file where you right clicked on it.

How do you create a relative path in JMeter?

Relative paths are resolved relative to the current working directory (which defaults to the bin/ directory). JMeter also supports paths relative to the directory containing the current test plan (JMX file). If the path name begins with "~/" (or whatever is in the jmeter. save.


1 Answers

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.

like image 85
madhatter160 Avatar answered Oct 13 '22 00:10

madhatter160