Chaitanya Revalla
Chaitanya Revalla

Reputation: 11

How to read relative file path in Jmeter using bean shell?where relative path is not in JMX file location

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

Note : In above example ,file upload.xml is not in director where JMX file is present.

I want to put upload.xml in c:/project/configfiles/ folder and for JMX files c:/project/scripts/ folders.

So how I can change the custom folder path in jmeter?

Upvotes: 1

Views: 2593

Answers (1)

Dmitri T
Dmitri T

Reputation: 168237

Be aware that since JMeter 3.1 it is recommended to use JSR223 Test Elements and Groovy language for any form of scripting so I would recommend switching to __groovy() function, the relevant code will look like:

${__groovy(new File(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir() +File.separator+ ".." + File.separator + 'configfiles' + File.separator + "upload.xml").getCanonicalPath(),)}

Demo:

JMeter Groovy Relative Path

Upvotes: 4

Related Questions