"infinite loop" with reload

24 views
Skip to first unread message

box3x4

unread,
Apr 11, 2016, 10:22:00 PM4/11/16
to CasperJS
hi guys.

i'm trying to do a script that fills a form and send.

but before this, i have to check if the form is available. my idea was that while the button to go to the form is not available it reloads the page.

casper.start ( url, function () {

   
this.waitForSelector ( 'body', function () {
           
while ( true )
               
if ( this.exists ( a.btn.btn-primary.mo-popover.btn-idsabled.btn-whitespace-normal.active ) )
                   
this.reload ();
               
else
                   
break;
   
});
               
});

but the problem is that it stops after about 4 reloads.

can you guys give me some help?

thx!

Ken

unread,
May 26, 2017, 3:11:46 AM5/26/17
to CasperJS
Actual waitforselector will wait until the selector appears, no need to keep reloading. You can control the timeout using - 


casper.options.waitTimeout = 10000;

Reply all
Reply to author
Forward
0 new messages