Skip to content Skip to sidebar Skip to footer

Adding Javascript Function To JMeter Using Jsr223

I am trying to get a javascript function work with jMeter test plan uing JSR223. It is used to decode a string. I have the below two functions which i need to implement in jmeter:

Solution 1:

You can import external JavaScript into JSR223 Sampler using load directive.

  1. Download latest release of crypto-js from https://github.com/brix/crypto-js/releases (I used 3.1.9) and unpack it to JMeter's "bin" folder
  2. Add the next line to the beginning of your JSR223 script:

    load('crypto-js-3.1.9/crypto-js.js');
    
  3. You should be able to access your JavaScript functions directly in the JSR223 Sampler

    JSR223 JavaScript


Be aware that JavaScript being interpreted via Rhino/Nashorn has serious performance drawbacks therefore if you are planning to call this funciton by many threads it makes more sense to rewrite your functions in Groovy.


Post a Comment for "Adding Javascript Function To JMeter Using Jsr223"