You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Anton Andreev <an...@yahoo.ca> on 2005/08/24 20:28:19 UTC

using counter with while controller

Hello everybody,

I'm trying to set up a counter to be used with while
controller and i'm having dificulty (my while loop
does not stop).  What i did, just before while
controller i have "user variables" where i set
{counter} to 0.  In while controller my condition is
${counter}<3 and i have counter (name {counter}, just
like user var) inside the loop which starts from 1 and
increments by 1 till 4.  My while loop does not stop. 
Please tell me what i'm doing wrong or if i have to
use something else to accomplish what i'm trying to
do.

Thank you,

Anton Andreev


	

	
		
__________________________________________________________ 
Find your next car at http://autos.yahoo.ca

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


Re: using counter with while controller

Posted by sebb <se...@gmail.com>.
On 17/12/2009, Deepak Shetty <sh...@gmail.com> wrote:
> hi
>  (one of) Your original question was why your debug sampler seemed to
>  interfere with your test. The answer is because your post processor is
>  attached as the child of the while controller, which means it would apply to
>  every sampler which is a child of the while controller (in your case Child 1
>  and the debug sampler under the while) and it will also apply to the
>  children of the for-each controller
>  Look at the scope rules in JMeter documents.
>  If you want your post processor to execute only once , you should create a
>  Test Action controller as the last sample in the While Controller and create
>  the post processor as the child of the Test Action. (It is probably easier
>  to just use the Counter)

Or just use a BeanShell Sampler to do the arithmetic.
If you end the script with "return null;" then no sample will be created.

Or you can use the __intSum() function.

>  You are getting incorrect values because your counter variable i is being
>  incremented too many times.
>  regards
>
> deepak
>
>
>
>  On Thu, Dec 17, 2009 at 1:01 AM, rosiere <sh...@gmail.com> wrote:
>
>  >
>  > Hello,
>  > I didn't use counter.
>  > This is my last test sequence:
>  > -- http request sampler reading the list of pages
>  >     |--> child: regex extractor to extract the total of pages, into a
>  > variable numPageMaxi
>  >
>  > -- while controller: ${__javaScript( ${i} < ${numPageMaxi} )}
>  >     |--> child 1: http request sampler to turn to the next (it takes
>  > parameters like ${__javaScript(${i}  * 50)}, ${__javaScript(${i}  * 50 +
>  > 50)}, for lower bound and upper bound)
>  >
>  >               |--> regex extractor to parse <tr> elements into an array:
>  > htmlResponse
>  >
>  >
>  >     |--> child 2: foreach controller on ${htmlResponse}
>  >               |--> http request sampler that sends extracted <tr> elements
>  > to a remote server
>  >
>  >
>  >     |--> child 3: BeanShell Post Processor that increments my own counter
>  > variable i, with the following     code:
>  >       String i = vars.get("i");
>  >      int counter = Integer.parseInt(i);
>  >      counter++;
>  >      vars.put("i", "" + counter);
>  >
>  >
>  > My BeanShell Postprocessor is a child of the while() controller that runs
>  > over the 2 pages, and not of the foreach() controller that runs over <tr>
>  > elements of each page.
>  >
>  > However even if I put the postprocessor in front of foreach(), my scenario
>  > yields still the wrong results (it takes the foreach()'s upper bound as my
>  > ${i}'s upper bound.
>  >
>  > I will try Counter instead of my own variable incremented by beanshell and
>  > see if it works better.
>  >
>  >
>  > Deepak Shetty wrote:
>  > >
>  > > Hi
>  > > whats your test look like? Its possible that you put the post processor
>  > in
>  > > the wrong place? was it a child of the for each instead of the sample or
>  > > something?
>  > >
>  > > Also FYI
>  > >
>  > http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Counter
>  > >
>  > > regards
>  > > deepak
>  > >
>  > >
>  > > On Wed, Dec 16, 2009 at 10:22 AM, rosiere <sh...@gmail.com>
>  > wrote:
>  > >
>  > >>
>  > >> Hello,
>  > >>
>  > >> I'm also facing problems with while controller, especially with its loop
>  > >> counter and an embedded foreach controller.
>  > >>
>  > >> I would like to go through a list of paginated result (like google's
>  > >> search
>  > >> result), and use a regex to parse every page.
>  > >>
>  > >> So I first parsed the list page and found the greatest page number (say
>  > >> 2).
>  > >> Then I defined a while controller with this condition:
>  > >> ${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user
>  > >> variable,
>  > >> initialized to 0)
>  > >> Then, inside my while controller, I identified HTTP request's format
>  > >> (parameter) needed to view each page (for example, page 1 needs 0, 50  ;
>  > >> page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
>  > >> with these 2 parameters:
>  > >>
>  > >> ${__javaScript(${i}  * 50)} (for lower bound)
>  > >> ${__javaScript(${i} *50 + 50)} (for upper bound)
>  > >>
>  > >> After the sampler I created a Debug Sampler to view the variables,
>  > >> including
>  > >> my counter "i".
>  > >> Afther the debug sampler, I used a BeanShell PostProcessor to increment
>  > >> i:
>  > >> String i = vars.get("i");
>  > >> int counter = Integer.parseInt(i);
>  > >> counter++;
>  > >> vars.put("i", "" + counter);
>  > >>
>  > >> My problem is that the http request sampler (that took upperbound and
>  > >> lowerbound computed from iteration counter i)ran only once with
>  > >> upperbound
>  > >> to 50 and lowerbound to 0, instead of twice even though I did get the
>  > >> total
>  > >> number of pages (2) and my PostProcessor ran twice.
>  > >>
>  > >> In order to fully iterate the pages I had to disable the Debug Sampler
>  > >> behind the http sampler.
>  > >>
>  > >> Could you please tell me why my debug sampler interferes with other
>  > >> samplers
>  > >> and the iteration counter?
>  > >> Thanks.
>  > >>
>  > >>
>  > >>
>  > >>
>  > >> sebb-2-2 wrote:
>  > >> >
>  > >> > See
>  > >> >
>  > >> >
>  > >>
>  > http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
>  > >> >
>  > >> > The While Controller condition needs to return the string "FALSE" or
>  > >> > "false" in order to exit the loop.
>  > >> >
>  > >> > ${counter}<3
>  > >> >
>  > >> > will never be "false"
>  > >> >
>  > >> > it will be perhaps "0<3" or "1<3" or "100<3" etc
>  > >> >
>  > >> > "You need to use a Javascript or Beanshell function to evaluate the
>  > >> > string as an expression."
>  > >> >
>  > >> > S
>  > >> > On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
>  > >> >> Hello everybody,
>  > >> >>
>  > >> >> I'm trying to set up a counter to be used with while
>  > >> >> controller and i'm having dificulty (my while loop
>  > >> >> does not stop).  What i did, just before while
>  > >> >> controller i have "user variables" where i set
>  > >> >> {counter} to 0.  In while controller my condition is
>  > >> >> ${counter}<3 and i have counter (name {counter}, just
>  > >> >> like user var) inside the loop which starts from 1 and
>  > >> >> increments by 1 till 4.  My while loop does not stop.
>  > >> >> Please tell me what i'm doing wrong or if i have to
>  > >> >> use something else to accomplish what i'm trying to
>  > >> >> do.
>  > >> >>
>  > >> >> Thank you,
>  > >> >>
>  > >> >> Anton Andreev
>  > >> >>
>  > >> >>
>  > >> >>
>  > >> >>
>  > >> >>
>  > >> >>
>  > >> >> __________________________________________________________
>  > >> >> Find your next car at http://autos.yahoo.ca
>  > >> >>
>  > >> >> ---------------------------------------------------------------------
>  > >> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > >> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  > >> >>
>  > >> >>
>  > >> >
>  > >> > ---------------------------------------------------------------------
>  > >> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > >> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  > >> >
>  > >> >
>  > >> >
>  > >>
>  > >> --
>  > >> View this message in context:
>  > >>
>  > http://old.nabble.com/using-counter-with-while-controller-tp702190p26815923.html
>  > >> Sent from the JMeter - User mailing list archive at Nabble.com.
>  > >>
>  > >>
>  > >> ---------------------------------------------------------------------
>  > >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  > >>
>  > >>
>  > >
>  > >
>  >
>  > --
>  > View this message in context:
>  > http://old.nabble.com/using-counter-with-while-controller-tp702190p26825058.html
>  > Sent from the JMeter - User mailing list archive at Nabble.com.
>  >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>  >
>  >
>

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


Re: using counter with while controller

Posted by Deepak Shetty <sh...@gmail.com>.
hi
(one of) Your original question was why your debug sampler seemed to
interfere with your test. The answer is because your post processor is
attached as the child of the while controller, which means it would apply to
every sampler which is a child of the while controller (in your case Child 1
and the debug sampler under the while) and it will also apply to the
children of the for-each controller
Look at the scope rules in JMeter documents.
If you want your post processor to execute only once , you should create a
Test Action controller as the last sample in the While Controller and create
the post processor as the child of the Test Action. (It is probably easier
to just use the Counter)

You are getting incorrect values because your counter variable i is being
incremented too many times.
regards
deepak


On Thu, Dec 17, 2009 at 1:01 AM, rosiere <sh...@gmail.com> wrote:

>
> Hello,
> I didn't use counter.
> This is my last test sequence:
> -- http request sampler reading the list of pages
>     |--> child: regex extractor to extract the total of pages, into a
> variable numPageMaxi
>
> -- while controller: ${__javaScript( ${i} < ${numPageMaxi} )}
>     |--> child 1: http request sampler to turn to the next (it takes
> parameters like ${__javaScript(${i}  * 50)}, ${__javaScript(${i}  * 50 +
> 50)}, for lower bound and upper bound)
>
>               |--> regex extractor to parse <tr> elements into an array:
> htmlResponse
>
>
>     |--> child 2: foreach controller on ${htmlResponse}
>               |--> http request sampler that sends extracted <tr> elements
> to a remote server
>
>
>     |--> child 3: BeanShell Post Processor that increments my own counter
> variable i, with the following     code:
>       String i = vars.get("i");
>      int counter = Integer.parseInt(i);
>      counter++;
>      vars.put("i", "" + counter);
>
>
> My BeanShell Postprocessor is a child of the while() controller that runs
> over the 2 pages, and not of the foreach() controller that runs over <tr>
> elements of each page.
>
> However even if I put the postprocessor in front of foreach(), my scenario
> yields still the wrong results (it takes the foreach()'s upper bound as my
> ${i}'s upper bound.
>
> I will try Counter instead of my own variable incremented by beanshell and
> see if it works better.
>
>
> Deepak Shetty wrote:
> >
> > Hi
> > whats your test look like? Its possible that you put the post processor
> in
> > the wrong place? was it a child of the for each instead of the sample or
> > something?
> >
> > Also FYI
> >
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Counter
> >
> > regards
> > deepak
> >
> >
> > On Wed, Dec 16, 2009 at 10:22 AM, rosiere <sh...@gmail.com>
> wrote:
> >
> >>
> >> Hello,
> >>
> >> I'm also facing problems with while controller, especially with its loop
> >> counter and an embedded foreach controller.
> >>
> >> I would like to go through a list of paginated result (like google's
> >> search
> >> result), and use a regex to parse every page.
> >>
> >> So I first parsed the list page and found the greatest page number (say
> >> 2).
> >> Then I defined a while controller with this condition:
> >> ${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user
> >> variable,
> >> initialized to 0)
> >> Then, inside my while controller, I identified HTTP request's format
> >> (parameter) needed to view each page (for example, page 1 needs 0, 50  ;
> >> page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
> >> with these 2 parameters:
> >>
> >> ${__javaScript(${i}  * 50)} (for lower bound)
> >> ${__javaScript(${i} *50 + 50)} (for upper bound)
> >>
> >> After the sampler I created a Debug Sampler to view the variables,
> >> including
> >> my counter "i".
> >> Afther the debug sampler, I used a BeanShell PostProcessor to increment
> >> i:
> >> String i = vars.get("i");
> >> int counter = Integer.parseInt(i);
> >> counter++;
> >> vars.put("i", "" + counter);
> >>
> >> My problem is that the http request sampler (that took upperbound and
> >> lowerbound computed from iteration counter i)ran only once with
> >> upperbound
> >> to 50 and lowerbound to 0, instead of twice even though I did get the
> >> total
> >> number of pages (2) and my PostProcessor ran twice.
> >>
> >> In order to fully iterate the pages I had to disable the Debug Sampler
> >> behind the http sampler.
> >>
> >> Could you please tell me why my debug sampler interferes with other
> >> samplers
> >> and the iteration counter?
> >> Thanks.
> >>
> >>
> >>
> >>
> >> sebb-2-2 wrote:
> >> >
> >> > See
> >> >
> >> >
> >>
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
> >> >
> >> > The While Controller condition needs to return the string "FALSE" or
> >> > "false" in order to exit the loop.
> >> >
> >> > ${counter}<3
> >> >
> >> > will never be "false"
> >> >
> >> > it will be perhaps "0<3" or "1<3" or "100<3" etc
> >> >
> >> > "You need to use a Javascript or Beanshell function to evaluate the
> >> > string as an expression."
> >> >
> >> > S
> >> > On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
> >> >> Hello everybody,
> >> >>
> >> >> I'm trying to set up a counter to be used with while
> >> >> controller and i'm having dificulty (my while loop
> >> >> does not stop).  What i did, just before while
> >> >> controller i have "user variables" where i set
> >> >> {counter} to 0.  In while controller my condition is
> >> >> ${counter}<3 and i have counter (name {counter}, just
> >> >> like user var) inside the loop which starts from 1 and
> >> >> increments by 1 till 4.  My while loop does not stop.
> >> >> Please tell me what i'm doing wrong or if i have to
> >> >> use something else to accomplish what i'm trying to
> >> >> do.
> >> >>
> >> >> Thank you,
> >> >>
> >> >> Anton Andreev
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> __________________________________________________________
> >> >> Find your next car at http://autos.yahoo.ca
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/using-counter-with-while-controller-tp702190p26815923.html
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/using-counter-with-while-controller-tp702190p26825058.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: using counter with while controller

Posted by rosiere <sh...@gmail.com>.
Hello,
I didn't use counter.
This is my last test sequence:
-- http request sampler reading the list of pages
     |--> child: regex extractor to extract the total of pages, into a
variable numPageMaxi

-- while controller: ${__javaScript( ${i} < ${numPageMaxi} )}
     |--> child 1: http request sampler to turn to the next (it takes
parameters like ${__javaScript(${i}  * 50)}, ${__javaScript(${i}  * 50 +
50)}, for lower bound and upper bound)

               |--> regex extractor to parse <tr> elements into an array:
htmlResponse


     |--> child 2: foreach controller on ${htmlResponse}
               |--> http request sampler that sends extracted <tr> elements
to a remote server


     |--> child 3: BeanShell Post Processor that increments my own counter
variable i, with the following     code:
      String i = vars.get("i");
      int counter = Integer.parseInt(i);
      counter++;
      vars.put("i", "" + counter);
               

My BeanShell Postprocessor is a child of the while() controller that runs
over the 2 pages, and not of the foreach() controller that runs over <tr>
elements of each page.

However even if I put the postprocessor in front of foreach(), my scenario
yields still the wrong results (it takes the foreach()'s upper bound as my
${i}'s upper bound.

I will try Counter instead of my own variable incremented by beanshell and
see if it works better.


Deepak Shetty wrote:
> 
> Hi
> whats your test look like? Its possible that you put the post processor in
> the wrong place? was it a child of the for each instead of the sample or
> something?
> 
> Also FYI
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Counter
> 
> regards
> deepak
> 
> 
> On Wed, Dec 16, 2009 at 10:22 AM, rosiere <sh...@gmail.com> wrote:
> 
>>
>> Hello,
>>
>> I'm also facing problems with while controller, especially with its loop
>> counter and an embedded foreach controller.
>>
>> I would like to go through a list of paginated result (like google's
>> search
>> result), and use a regex to parse every page.
>>
>> So I first parsed the list page and found the greatest page number (say
>> 2).
>> Then I defined a while controller with this condition:
>> ${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user
>> variable,
>> initialized to 0)
>> Then, inside my while controller, I identified HTTP request's format
>> (parameter) needed to view each page (for example, page 1 needs 0, 50  ;
>> page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
>> with these 2 parameters:
>>
>> ${__javaScript(${i}  * 50)} (for lower bound)
>> ${__javaScript(${i} *50 + 50)} (for upper bound)
>>
>> After the sampler I created a Debug Sampler to view the variables,
>> including
>> my counter "i".
>> Afther the debug sampler, I used a BeanShell PostProcessor to increment
>> i:
>> String i = vars.get("i");
>> int counter = Integer.parseInt(i);
>> counter++;
>> vars.put("i", "" + counter);
>>
>> My problem is that the http request sampler (that took upperbound and
>> lowerbound computed from iteration counter i)ran only once with
>> upperbound
>> to 50 and lowerbound to 0, instead of twice even though I did get the
>> total
>> number of pages (2) and my PostProcessor ran twice.
>>
>> In order to fully iterate the pages I had to disable the Debug Sampler
>> behind the http sampler.
>>
>> Could you please tell me why my debug sampler interferes with other
>> samplers
>> and the iteration counter?
>> Thanks.
>>
>>
>>
>>
>> sebb-2-2 wrote:
>> >
>> > See
>> >
>> >
>> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
>> >
>> > The While Controller condition needs to return the string "FALSE" or
>> > "false" in order to exit the loop.
>> >
>> > ${counter}<3
>> >
>> > will never be "false"
>> >
>> > it will be perhaps "0<3" or "1<3" or "100<3" etc
>> >
>> > "You need to use a Javascript or Beanshell function to evaluate the
>> > string as an expression."
>> >
>> > S
>> > On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
>> >> Hello everybody,
>> >>
>> >> I'm trying to set up a counter to be used with while
>> >> controller and i'm having dificulty (my while loop
>> >> does not stop).  What i did, just before while
>> >> controller i have "user variables" where i set
>> >> {counter} to 0.  In while controller my condition is
>> >> ${counter}<3 and i have counter (name {counter}, just
>> >> like user var) inside the loop which starts from 1 and
>> >> increments by 1 till 4.  My while loop does not stop.
>> >> Please tell me what i'm doing wrong or if i have to
>> >> use something else to accomplish what i'm trying to
>> >> do.
>> >>
>> >> Thank you,
>> >>
>> >> Anton Andreev
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> __________________________________________________________
>> >> Find your next car at http://autos.yahoo.ca
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/using-counter-with-while-controller-tp702190p26815923.html
>> Sent from the JMeter - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/using-counter-with-while-controller-tp702190p26825058.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: using counter with while controller

Posted by Deepak Shetty <sh...@gmail.com>.
Hi
whats your test look like? Its possible that you put the post processor in
the wrong place? was it a child of the for each instead of the sample or
something?

Also FYI
http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Counter

regards
deepak


On Wed, Dec 16, 2009 at 10:22 AM, rosiere <sh...@gmail.com> wrote:

>
> Hello,
>
> I'm also facing problems with while controller, especially with its loop
> counter and an embedded foreach controller.
>
> I would like to go through a list of paginated result (like google's search
> result), and use a regex to parse every page.
>
> So I first parsed the list page and found the greatest page number (say 2).
> Then I defined a while controller with this condition:
> ${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user variable,
> initialized to 0)
> Then, inside my while controller, I identified HTTP request's format
> (parameter) needed to view each page (for example, page 1 needs 0, 50  ;
> page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
> with these 2 parameters:
>
> ${__javaScript(${i}  * 50)} (for lower bound)
> ${__javaScript(${i} *50 + 50)} (for upper bound)
>
> After the sampler I created a Debug Sampler to view the variables,
> including
> my counter "i".
> Afther the debug sampler, I used a BeanShell PostProcessor to increment i:
> String i = vars.get("i");
> int counter = Integer.parseInt(i);
> counter++;
> vars.put("i", "" + counter);
>
> My problem is that the http request sampler (that took upperbound and
> lowerbound computed from iteration counter i)ran only once with upperbound
> to 50 and lowerbound to 0, instead of twice even though I did get the total
> number of pages (2) and my PostProcessor ran twice.
>
> In order to fully iterate the pages I had to disable the Debug Sampler
> behind the http sampler.
>
> Could you please tell me why my debug sampler interferes with other
> samplers
> and the iteration counter?
> Thanks.
>
>
>
>
> sebb-2-2 wrote:
> >
> > See
> >
> >
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
> >
> > The While Controller condition needs to return the string "FALSE" or
> > "false" in order to exit the loop.
> >
> > ${counter}<3
> >
> > will never be "false"
> >
> > it will be perhaps "0<3" or "1<3" or "100<3" etc
> >
> > "You need to use a Javascript or Beanshell function to evaluate the
> > string as an expression."
> >
> > S
> > On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
> >> Hello everybody,
> >>
> >> I'm trying to set up a counter to be used with while
> >> controller and i'm having dificulty (my while loop
> >> does not stop).  What i did, just before while
> >> controller i have "user variables" where i set
> >> {counter} to 0.  In while controller my condition is
> >> ${counter}<3 and i have counter (name {counter}, just
> >> like user var) inside the loop which starts from 1 and
> >> increments by 1 till 4.  My while loop does not stop.
> >> Please tell me what i'm doing wrong or if i have to
> >> use something else to accomplish what i'm trying to
> >> do.
> >>
> >> Thank you,
> >>
> >> Anton Andreev
> >>
> >>
> >>
> >>
> >>
> >>
> >> __________________________________________________________
> >> Find your next car at http://autos.yahoo.ca
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/using-counter-with-while-controller-tp702190p26815923.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: using counter with while controller

Posted by rosiere <sh...@gmail.com>.
Another interference, with foreach controller that followed the http sampler:

I attached a foreach controller, behind the counter incrementing beanshell
postprocessor. The goal is to iterate on "tr" elements of each page, and
send one http request according to each "tr" elements' content.

So if I have 2 pages to go through, and each page contains 50 <tr> elements
I will send 50 http request on each page. 

However when running my scenario I found that my outer while controller's
counter "i" was set to <tr> indexes, and set from 1 to 50. Then I lost again
the second page.

So could anyone explain such intereference between controllers even though
they did not seem to share any variable?


rosiere wrote:
> 
> Hello,
> 
> I'm also facing problems with while controller, especially with its loop
> counter and an embedded foreach controller.
> 
> I would like to go through a list of paginated result (like google's
> search result), and use a regex to parse every page.
> 
> So I first parsed the list page and found the greatest page number (say
> 2).
> Then I defined a while controller with this condition:
> ${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user variable,
> initialized to 0)
> Then, inside my while controller, I identified HTTP request's format
> (parameter) needed to view each page (for example, page 1 needs 0, 50  ;
> page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
> with these 2 parameters:
> 
> ${__javaScript(${i}  * 50)} (for lower bound)
> ${__javaScript(${i} *50 + 50)} (for upper bound)
> 
> "
> The sampler contained a regex extractor to retrieve and parsed <tr>
> elements on the current page. the extractor matched all occurrences of
> <tr> according to some rules.
> Then the extractor put them into an variable that would represent an array
> and would be used by an embedded foreach controller inside the while
> controller."
> 
> After the sampler I created a Debug Sampler to view the variables,
> including my counter "i".
> Afther the debug sampler, I used a BeanShell PostProcessor to increment i:
> String i = vars.get("i");
> int counter = Integer.parseInt(i);
> counter++;
> vars.put("i", "" + counter);
> 
> My problem is that the http request sampler (that took upperbound and
> lowerbound computed from iteration counter i)ran only once with upperbound
> to 50 and lowerbound to 0, instead of twice even though I did get the
> total number of pages (2) and my PostProcessor ran twice.
> 
> In order to fully iterate the pages I had to disable the Debug Sampler 
> behind the http sampler.
> 
> Could you please tell me why my debug sampler interferes with other
> samplers and the iteration counter?
> Thanks.
> 
> 
> 
> 
> sebb-2-2 wrote:
>> 
>> See
>> 
>> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
>> 
>> The While Controller condition needs to return the string "FALSE" or
>> "false" in order to exit the loop.
>> 
>> ${counter}<3
>> 
>> will never be "false"
>> 
>> it will be perhaps "0<3" or "1<3" or "100<3" etc
>> 
>> "You need to use a Javascript or Beanshell function to evaluate the
>> string as an expression."
>> 
>> S
>> On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
>>> Hello everybody,
>>> 
>>> I'm trying to set up a counter to be used with while
>>> controller and i'm having dificulty (my while loop
>>> does not stop).  What i did, just before while
>>> controller i have "user variables" where i set
>>> {counter} to 0.  In while controller my condition is
>>> ${counter}<3 and i have counter (name {counter}, just
>>> like user var) inside the loop which starts from 1 and
>>> increments by 1 till 4.  My while loop does not stop.
>>> Please tell me what i'm doing wrong or if i have to
>>> use something else to accomplish what i'm trying to
>>> do.
>>> 
>>> Thank you,
>>> 
>>> Anton Andreev
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> __________________________________________________________
>>> Find your next car at http://autos.yahoo.ca
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>> 
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/using-counter-with-while-controller-tp702190p26816100.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: using counter with while controller

Posted by rosiere <sh...@gmail.com>.
Hello,

I'm also facing problems with while controller, especially with its loop
counter and an embedded foreach controller.

I would like to go through a list of paginated result (like google's search
result), and use a regex to parse every page.

So I first parsed the list page and found the greatest page number (say 2).
Then I defined a while controller with this condition:
${__javaScript( ${i} < ${numPageMaxi} )} (i is a predefined user variable,
initialized to 0)
Then, inside my while controller, I identified HTTP request's format
(parameter) needed to view each page (for example, page 1 needs 0, 50  ;
page 2 needs 50, 100 , and so on ) and I created an HTTP request sampler
with these 2 parameters:

${__javaScript(${i}  * 50)} (for lower bound)
${__javaScript(${i} *50 + 50)} (for upper bound)

After the sampler I created a Debug Sampler to view the variables, including
my counter "i".
Afther the debug sampler, I used a BeanShell PostProcessor to increment i:
String i = vars.get("i");
int counter = Integer.parseInt(i);
counter++;
vars.put("i", "" + counter);

My problem is that the http request sampler (that took upperbound and
lowerbound computed from iteration counter i)ran only once with upperbound
to 50 and lowerbound to 0, instead of twice even though I did get the total
number of pages (2) and my PostProcessor ran twice.

In order to fully iterate the pages I had to disable the Debug Sampler 
behind the http sampler.

Could you please tell me why my debug sampler interferes with other samplers
and the iteration counter?
Thanks.




sebb-2-2 wrote:
> 
> See
> 
> http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller
> 
> The While Controller condition needs to return the string "FALSE" or
> "false" in order to exit the loop.
> 
> ${counter}<3
> 
> will never be "false"
> 
> it will be perhaps "0<3" or "1<3" or "100<3" etc
> 
> "You need to use a Javascript or Beanshell function to evaluate the
> string as an expression."
> 
> S
> On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
>> Hello everybody,
>> 
>> I'm trying to set up a counter to be used with while
>> controller and i'm having dificulty (my while loop
>> does not stop).  What i did, just before while
>> controller i have "user variables" where i set
>> {counter} to 0.  In while controller my condition is
>> ${counter}<3 and i have counter (name {counter}, just
>> like user var) inside the loop which starts from 1 and
>> increments by 1 till 4.  My while loop does not stop.
>> Please tell me what i'm doing wrong or if i have to
>> use something else to accomplish what i'm trying to
>> do.
>> 
>> Thank you,
>> 
>> Anton Andreev
>> 
>> 
>> 
>> 
>> 
>> 
>> __________________________________________________________
>> Find your next car at http://autos.yahoo.ca
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> 
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/using-counter-with-while-controller-tp702190p26815923.html
Sent from the JMeter - User mailing list archive at Nabble.com.


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


Re: using counter with while controller

Posted by sebb <se...@gmail.com>.
See

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#While_Controller

The While Controller condition needs to return the string "FALSE" or
"false" in order to exit the loop.

${counter}<3

will never be "false"

it will be perhaps "0<3" or "1<3" or "100<3" etc

You need to use a Javascript or Beanshell function to evaluate the
string as an expression.

S
On 24/08/05, Anton Andreev <an...@yahoo.ca> wrote:
> Hello everybody,
> 
> I'm trying to set up a counter to be used with while
> controller and i'm having dificulty (my while loop
> does not stop).  What i did, just before while
> controller i have "user variables" where i set
> {counter} to 0.  In while controller my condition is
> ${counter}<3 and i have counter (name {counter}, just
> like user var) inside the loop which starts from 1 and
> increments by 1 till 4.  My while loop does not stop.
> Please tell me what i'm doing wrong or if i have to
> use something else to accomplish what i'm trying to
> do.
> 
> Thank you,
> 
> Anton Andreev
> 
> 
> 
> 
> 
> 
> __________________________________________________________
> Find your next car at http://autos.yahoo.ca
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> 
>

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