Access to JMeter script path

前端 未结 4 515
-上瘾入骨i
-上瘾入骨i 2020-12-29 09:46

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

4条回答
  •  萌比男神i
    2020-12-29 10:03

    By saying "current script's absolute physical path", I am guessing OP is referring to the location where the testplan (jmx file) is loaded from. I needed exactly this to generate a CSV file from BeanShell script at the beginning of the run, which is subsequently used in a CSV Data Set Config to read back, so I wanted the script to work just like how the later works when no path is specified. I went through the JMeter source and found this working solution:

    import org.apache.jmeter.services.FileServer;
    log.info(FileServer.getFileServer().getBaseDir());
    

    I tested this and saw the correct path in the jmeter.log.

提交回复
热议问题