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 <[email protected]> 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 <[email protected]> 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: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>> >
>>
>> --
>> 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: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
> 
> 

-- 
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to