Quantcast

While controller is not ending the loop

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Das
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

While controller is not ending the loop

Das
Hi,

I am trying with while controller but not successful.Please help

Scenario:

Login
Search
Keep click on Next button. go to next page and click next button until
there is no products available.
logout

So I have extract the "Next" from "search" then used while loop.

Login
Search
--regular expression ex
While controller >>${__javaScript(!"${VAR2}".equals("Next"))
--Click next sampler
Logout

When I am running the script, the https request with all the nexts are
running properly. But when the condition is failed also "click next"
samplers are running

Can someone help what I am missing.

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: While controller is not ending the loop

glinius@live.com
This post has NOT been accepted by the mailing list yet.
You have syntax error in JavaScript therefore your While Controller does not work at all.

The correct way to compare 2 strings in JavaScript is using "==" operator

Therefore if you want to process unless your "${VAR2}" is not equal to "Next" you need to amend your expression as follows:

${__javaScript("${VAR2}" != "Next",)}
Once "${VAR2}" becomes "Next" - JMeter will exit the While loop and proceed.

See Using the While Controller in JMeter article for more information on using While loops in JMeter tests.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: While controller is not ending the loop

shettyd
In reply to this post by Das
Hi
javascript doesnt have a .equals method if I remember correctly. Check your
log for errors.
${__javaScript("${VAR2}" == "Next")} is probably what you are looking for


regards
deepak

On Mon, Feb 6, 2017 at 4:35 AM, Sankar Das <[hidden email]>
wrote:

> Hi,
>
> I am trying with while controller but not successful.Please help
>
> Scenario:
>
> Login
> Search
> Keep click on Next button. go to next page and click next button until
> there is no products available.
> logout
>
> So I have extract the "Next" from "search" then used while loop.
>
> Login
> Search
> --regular expression ex
> While controller >>${__javaScript(!"${VAR2}".equals("Next"))
> --Click next sampler
> Logout
>
> When I am running the script, the https request with all the nexts are
> running properly. But when the condition is failed also "click next"
> samplers are running
>
> Can someone help what I am missing.
>
> Thanks
>
Das
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: While controller is not ending the loop

Das
Thanks for the reply. I tried with that one too. But the thing is the while
loop is not ending because it trying to meet the conditions.

I tried with providing a assertion and running the while loop. Now the loop
is ending but my last sampler is getting failed and that is getting
reflected as error in the report.

How can I end the loop ?

On Feb 6, 2017 9:37 PM, "Deepak Shetty" <[hidden email]> wrote:

> Hi
> javascript doesnt have a .equals method if I remember correctly. Check your
> log for errors.
> ${__javaScript("${VAR2}" == "Next")} is probably what you are looking for
>
>
> regards
> deepak
>
> On Mon, Feb 6, 2017 at 4:35 AM, Sankar Das <[hidden email]>
> wrote:
>
> > Hi,
> >
> > I am trying with while controller but not successful.Please help
> >
> > Scenario:
> >
> > Login
> > Search
> > Keep click on Next button. go to next page and click next button until
> > there is no products available.
> > logout
> >
> > So I have extract the "Next" from "search" then used while loop.
> >
> > Login
> > Search
> > --regular expression ex
> > While controller >>${__javaScript(!"${VAR2}".equals("Next"))
> > --Click next sampler
> > Logout
> >
> > When I am running the script, the https request with all the nexts are
> > running properly. But when the condition is failed also "click next"
> > samplers are running
> >
> > Can someone help what I am missing.
> >
> > Thanks
> >
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: While controller is not ending the loop

shettyd
>I tried with providing a assertion and running the while loop. Now the
loop is ending
Makes no sense. An assertion doesnt impact the running of the loop

>How can I end the loop ?
whenever the condition returns  "false" , the loop will end . You might not
be doing something like resetting the value of the variable (missing in
your original snippet(
 Add a debug sampler within the loop and see. And as before always inspect
jmeter.log

On Mon, Feb 6, 2017 at 11:56 AM, Sankar Das <[hidden email]>
wrote:

> Thanks for the reply. I tried with that one too. But the thing is the while
> loop is not ending because it trying to meet the conditions.
>
> I tried with providing a assertion and running the while loop. Now the loop
> is ending but my last sampler is getting failed and that is getting
> reflected as error in the report.
>
> How can I end the loop ?
>
> On Feb 6, 2017 9:37 PM, "Deepak Shetty" <[hidden email]> wrote:
>
> > Hi
> > javascript doesnt have a .equals method if I remember correctly. Check
> your
> > log for errors.
> > ${__javaScript("${VAR2}" == "Next")} is probably what you are looking for
> >
> >
> > regards
> > deepak
> >
> > On Mon, Feb 6, 2017 at 4:35 AM, Sankar Das <[hidden email]>
> > wrote:
> >
> > > Hi,
> > >
> > > I am trying with while controller but not successful.Please help
> > >
> > > Scenario:
> > >
> > > Login
> > > Search
> > > Keep click on Next button. go to next page and click next button until
> > > there is no products available.
> > > logout
> > >
> > > So I have extract the "Next" from "search" then used while loop.
> > >
> > > Login
> > > Search
> > > --regular expression ex
> > > While controller >>${__javaScript(!"${VAR2}".equals("Next"))
> > > --Click next sampler
> > > Logout
> > >
> > > When I am running the script, the https request with all the nexts are
> > > running properly. But when the condition is failed also "click next"
> > > samplers are running
> > >
> > > Can someone help what I am missing.
> > >
> > > Thanks
> > >
> >
>
Loading...