Search code examples
javascriptjmeterbeanshell

JMeter - Replace inline javaScript to BeanShell


I need to send elapsed time in header of each request. To do this I use inline javaScript in HTTP Header Manager as following:

enter image description here

If there is any way to do the same with BeanShell instead of javaScript?


Solution

  • I think since JMeter 3.1 you are supposed to be using JSR223 Test Elements and Groovy language for scripting so here is something similar for the __groovy() function:

    ${__groovy(((System.currentTimeMillis() - (vars.get('TESTSTART.MS') as long)) / 1000).round(1),)} 
    

    More information: Apache Groovy - Why and How You Should Use It