Bug 54362 - Error in using Javascript in While Controller.
Summary: Error in using Javascript in While Controller.
Status: RESOLVED INVALID
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-31 05:56 UTC by ghazall_alii
Modified: 2012-12-31 13:01 UTC (History)
1 user (show)



Attachments
Attached Jmx file for your reference. (8.46 KB, application/octet-stream)
2012-12-31 06:13 UTC, ghazall_alii
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ghazall_alii 2012-12-31 05:56:14 UTC
I am using While Controller with Condition:

${_javaScript("${DONE}" ! = "Resolved and Downloaded";)}

Where initially DONE="Not Assigned yet"

After few Iterations DONE changes and has value "Resolved and Downloaded"(which I check in Debug Sampler)

but loop continues and doesn't quit.In .log file it is getting this error:

ERROR - jmeter.functions.JavaScript: Error processing Javascript: ['Nothing Assigned Yet' ! = 'Resolved and Downloaded' ]
 org.mozilla.javascript.EvaluatorException: missing ; before statement (<cmd>#1)
	at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109)
	at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96)
	at org.mozilla.javascript.Parser.addError(Parser.java:230)
	at org.mozilla.javascript.Parser.addError(Parser.java:208)
	at org.mozilla.javascript.Parser.reportError(Parser.java:265)
	at org.mozilla.javascript.Parser.reportError(Parser.java:252)
	at org.mozilla.javascript.Parser.reportError(Parser.java:245)
	at org.mozilla.javascript.Parser.autoInsertSemicolon(Parser.java:1109)
	at org.mozilla.javascript.Parser.statementHelper(Parser.java:1086)
	at org.mozilla.javascript.Parser.statement(Parser.java:943)
	at org.mozilla.javascript.Parser.parse(Parser.java:568)
	at org.mozilla.javascript.Parser.parse(Parser.java:506)
	at org.mozilla.javascript.Context.compileImpl(Context.java:2401)
	at org.mozilla.javascript.Context.compileString(Context.java:1367)
	at org.mozilla.javascript.Context.compileString(Context.java:1356)
	at org.mozilla.javascript.Context.evaluateString(Context.java:1108)
	at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:88)
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:145)
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:120)
	at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:99)
	at org.apache.jmeter.control.WhileController.getCondition(WhileController.java:125)
	at org.apache.jmeter.control.WhileController.endOfLoop(WhileController.java:56)
	at org.apache.jmeter.control.WhileController.next(WhileController.java:102)
	at org.apache.jmeter.control.WhileController.nextIsNull(WhileController.java:82)
	at org.apache.jmeter.control.GenericController.next(GenericController.java:167)
	at org.apache.jmeter.control.WhileController.next(WhileController.java:106)
	at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:211)
	at org.apache.jmeter.control.GenericController.next(GenericController.java:172)
	at org.apache.jmeter.control.LoopController.next(LoopController.java:108)
	at org.apache.jmeter.threads.AbstractThreadGroup.next(AbstractThreadGroup.java:86)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:277)
	at java.lang.Thread.run(Unknown Source)
Comment 1 ghazall_alii 2012-12-31 06:13:36 UTC
Created attachment 29800 [details]
Attached Jmx file for your reference.
Comment 2 ghazall_alii 2012-12-31 06:50:59 UTC
I also tried with single quotes , like

${_javaScript('${DONE}' ! = 'Resolved and Downloaded')}

withoutspaces, something like

${_javaScript("${DONE}" ! = "ResolvedandDownloaded")}

nothing woked. got same exception each time.
Comment 3 Philippe Mouawad 2012-12-31 13:01:01 UTC
Hello,
I don't understand , your JMX attached file works fine for me.

But the expressions you show in comments are wrong:

${_javaScript("${DONE}" ! = "Resolved and Downloaded";)} => there is a space character between ! and = , and _javaScript should be __javaScript

Same for:
${_javaScript('${DONE}' ! = 'Resolved and Downloaded')}


and 
${_javaScript("${DONE}" ! = "ResolvedandDownloaded")}


Just put this:
${__javaScript("${DONE}"!="Resolved and Risk Data Downloaded")}

and it works OK
Comment 4 The ASF infrastructure team 2022-09-24 20:37:52 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3023