Skip to content Skip to sidebar Skip to footer

Adding Javascript Function To JMeter

I am trying to get a javascript function work with jMeter test plan. It is used to decode a string. function decode(str) { var strtodecrypt = str.split('-'); var msglength

Solution 1:

You can try to use as well JSR223 Sampler with script language set to javascript (Language: JavaScript).
It will process your script (2nd version), variable set and available in debug Sampler results.


Solution 2:

You should WebDriver plugin for that. It can be configured as IE/Firefox/Chrome or even Selenium.

The documentation here

This is how you configure IE web driver


Solution 3:

For anyone reading this years later:

Calling javascript function is possible from a BSF PostProcessor.

You need to define your function higher up in the file than where it is used.

This means this works:

function decode(str) {
    (...... do stuff......)
    return something;
}

var bar = decode("foo");
vars.put("someVariableName", bar);

However this doesn't work:

var bar = decode("foo"); // <--- Compile error, undefined function 'decode'
vars.put("someVariableName", bar);

function decode(str) {
    (...... do stuff......)
    return something;
}

Post a Comment for "Adding Javascript Function To JMeter"