You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Vladimir Tsygankov <Vl...@contera.sp.ru> on 2005/02/17 18:54:33 UTC

Problems with "If" controller

Hello to all.
I have problems with "If" controller.
I would like to compare some extracted from certain page variables with
actual (expected) ones. 
It needs to decide if the test script performed correctly or not. If the
result is not agree 
with the correct values we want to send a message to Console (test is
performing without GUI).

Test plan is going to look like:
...
- HTTP Request
- Reg Exp Extractor (creates a variable MyVar1)
- Loop for all ${MyVar1_g#}
  - If Controller 
     < compares ${MyVar1_g#} with correct value taken from user
parameter or file (function CSVRead) >
    - send a message to Conlose ("incorrect test result")
...

My questions:
1. I couldn't force "If" to work with JMeter functions.
How can I use in controller "If" expressions like 
${__CSVRead(<file-name>,${__counter(false,refC)}-1)}!=${MyVar1_${refC}}
or ${user-parameter1}!=${MyVar1_g1} 
or ${user-parameter${__counter(false,refC)}}!=${MyVar1_g${refC}} 
etc.
2. Can I have an access from JaveScript code to JMeter variables like
${MyVar1_g#}?
3. How can I send any string to Console?
Any other ideas?

The best regards and thanks in advance,
Vladimir


---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: Problems with "If" controller

Posted by sebb <se...@gmail.com>.
On Thu, 17 Feb 2005 20:54:33 +0300, Vladimir Tsygankov
<Vl...@contera.sp.ru> wrote:
> Hello to all.
> I have problems with "If" controller.
> I would like to compare some extracted from certain page variables with
> actual (expected) ones.
> It needs to decide if the test script performed correctly or not. If the
> result is not agree
> with the correct values we want to send a message to Console (test is
> performing without GUI).
> 
> Test plan is going to look like:
> ...
> - HTTP Request
> - Reg Exp Extractor (creates a variable MyVar1)
> - Loop for all ${MyVar1_g#}
>   - If Controller
>      < compares ${MyVar1_g#} with correct value taken from user
> parameter or file (function CSVRead) >
>     - send a message to Conlose ("incorrect test result")
> ...
> 
> My questions:
> 1. I couldn't force "If" to work with JMeter functions.
> How can I use in controller "If" expressions like
> ${__CSVRead(<file-name>,${__counter(false,refC)}-1)}!=${MyVar1_${refC}}
> or ${user-parameter1}!=${MyVar1_g1}
> or ${user-parameter${__counter(false,refC)}}!=${MyVar1_g${refC}}
> etc.

The If  Controller requires a valid JavaScript expression.
As far as I know, strings need to be enclosed in quotes, i.e. 

Use:      "${Var1}" != "${Var2}"

Not:       ${Var1}   !=  ${Var2}

> 2. Can I have an access from JaveScript code to JMeter variables like
> ${MyVar1_g#}?

Yes.

> 3. How can I send any string to Console?

${__logn(any string,OUT)}

> Any other ideas?

Check jmeter.log for error/warning messages.

Start with simple constant expressions and replace constants with
functions one by one.

> The best regards and thanks in advance,
> Vladimir
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org