0

I am testing an API using JMeter which works fine locally. However, when I upload my test plan and parameters file to Blazemeter, it doesn't run well and throws error

javax.script.ScriptException: ReferenceError: "getFinancialDashboard_responseCode" is not defined in at line number 1

in logs. getFinancialDashboard_responseCode is a property I have defined in previous thread group and its value is being passed to teardown thread group to push notifications to a messaging app based on response code.

I have tried to define this property in test configurations on Blazemeter but that serves a different purpose i.e. Overrides the value. Defining this property in configurations on Blazemeter makes the test execute successfully but overrides the current value set in thread group and making it to send undesired notifications.

Here is the full exception log:

2018-05-19 10:46:02,874 ERROR o.a.j.c.IfController: If_getIspDashboardData_Fails: error while processing [getFinancialDashboard_responseCode != 200;]
javax.script.ScriptException: ReferenceError: "getFinancialDashboard_responseCode" is not defined in <eval> at line number 1
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:454) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) ~[nashorn.jar:?]
at org.apache.jmeter.control.IfController$NashornJsEngine.evaluate(IfController.java:124) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.IfController.evaluateCondition(IfController.java:185) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.IfController.next(IfController.java:239) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:219) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.GenericController.next(GenericController.java:173) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.LoopController.next(LoopController.java:128) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.GenericController.next(GenericController.java:173) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.control.LoopController.next(LoopController.java:128) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:87) [ApacheJMeter_core.jar:4.0 r1823414]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:248) [ApacheJMeter_core.jar:4.0 r1823414]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_141]
Caused by: jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "getFinancialDashboard_responseCode" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1441) ~[nashorn.jar:?]
at jdk.nashorn.internal.scripts.Script$1$\^eval\_.:program(<eval>:1) ~[?:?]
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) ~[nashorn.jar:?]
at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449) ~[nashorn.jar:?]
... 15 more

How to handle properties in Blazemeter so that values can be exchanged between thread groups?

James Z
  • 12,209
  • 10
  • 24
  • 44

1 Answers1

0

I strongly doubt your test "works fine locally" as most probably you have configured your If Controller like:

JMeter If Controller - BAD

which is not correct in terms of JavaScript. If you really have getFinancialDashboard_responseCode defined somewhere you should be using the following condition:

${__groovy(!props.get('getFinancialDashboard_responseCode').equals('200'),)}

Also make sure that Interpret Condition as Variable Expression? box is checked:

JMeter Groovy

More information: 6 Tips for JMeter If Controller Usage


If for any reason you would like to continue using JavaScript you will need to amend your condition to:

  • fetch the property using __P() function
  • surround the property function call and 200 with quotation marks like:

    "${__P(getFinancialDashboard_responseCode,)}" != "200"
    

But be aware that from performance perspective JavaScript works much worse comparing to Groovy.

Also be aware that you should be able to reach out to BlazeMeter Support, it should be faster and the chance of getting a real professional response will be much higher than in the community forums.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks for your answer. I have already used the property value using ```__property``` function but still it doesn't work on Blazemeter whereas works well locally. I will get in touch with Blazemeter support. – Ehtesham Ahmed May 21 '18 at 05:57