JMeter upload file with relative path from the jmx file

Yes. (This was confirmed in JMeter v2.9)

You can use the following BeanShell expression in the filename input field:

${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}<YOUR FILENAME HERE>

So if your file, “upload.jpg” was located in the same folder as your JMX test file, the complete value would be

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

To keep it a bit cleaner, add a “User defined variables” config element where you assign the base of the expression to a variable e.g

SCRIPT_PATH = ${__BeanShell( ...etc

Then your file path input value would read a more readable:

${SCRIPT_PATH}upload.jpg

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)