You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Guruprasad R <gu...@gmail.com> on 2013/11/12 10:19:44 UTC
Checking conditions in a while loop with ${__javaScript()}
Hi All.
I am using the below statement in a while loop.
${__javaScript("${ResponseExtractor_g0}" != (("NA") || ("SUCCESS") ||
("Exception")))}
It exits the while loop only when it finds NA. Its not working for the
other two strings SUCCESS and Exception.
I also tried the below statement where it doesn't exit the while loop at
all:
${__javaScript(("${ResponseExtractor_g0}" != "NA") ||
("${ResponseExtractor_g0}" != "SUCCESS") || ("${ResponseExtractor_g0}" !=
"Exception"))}
Kindly help.
Regards,
Guru
Re: Checking conditions in a while loop with ${__javaScript()}
Posted by sebb <se...@gmail.com>.
On 12 November 2013 09:19, Guruprasad R <gu...@gmail.com> wrote:
> Hi All.
>
> I am using the below statement in a while loop.
>
> ${__javaScript("${ResponseExtractor_g0}" != (("NA") || ("SUCCESS") ||
> ("Exception")))}
>
> It exits the while loop only when it finds NA. Its not working for the
> other two strings SUCCESS and Exception.
That's because the value of
(("NA") || ("SUCCESS") || ("Exception"))
is
"NA"
This can easily be verified by using a BSF : Javascript sampler to
test the code.
> I also tried the below statement where it doesn't exit the while loop at
> all:
> ${__javaScript(("${ResponseExtractor_g0}" != "NA") ||
> ("${ResponseExtractor_g0}" != "SUCCESS") || ("${ResponseExtractor_g0}" !=
> "Exception"))}
Suppose ResponseExtractor_g0 == "NA".
Then the condition is clearly:
false || true || true => true
In fact the condition will always be true regardless of the value of
the variable.
You need to fix the condition; have a look at De Morgan's laws of
boolean logic [1]
[1] http://en.wikipedia.org/wiki/De_Morgan%27s_laws
> Kindly help.
>
> Regards,
> Guru
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org