jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Checking conditions in a while loop with ${__javaScript()}
Date Sun, 17 Nov 2013 00:28:46 GMT
On 12 November 2013 09:19, Guruprasad R <guruprasad81@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


Mime
View raw message