New Solution for CasperJS Navigation Step Flow Control; infinite loop, break, continue, ... by label() and goto()

1,938 views
Skip to first unread message

Hiro Yotsumoto

unread,
Aug 23, 2012, 10:33:10 AM8/23/12
to casp...@googlegroups.com
Hello, CasperJS community.

I am using CasperJS for some my projects. Thank you very much, Nicolas.

By the way, sometimes, I would like to describe the logic, 
like infinite loop and conditional break. 
For example:

  while(true) {
    DO SOMETHING
    if( CHECK CONDITION ) { break; }
    DO SOMETHING
  }

However, I can not find out the solution in current CasperJS.
So, I tried to solve this problem by my own way.

The project result is on my GitHub repository

I realized CasperJS Navigation Step Flow Control 
by adding new label() and goto() functions.

This repository has useful sample scripts too.
Please feel free to try them.


Thank you.
Hiro Yotsumoto

Nicolas Perriault

unread,
Aug 23, 2012, 10:59:25 AM8/23/12
to casp...@googlegroups.com
On Thu, Aug 23, 2012 at 4:33 PM, Hiro Yotsumoto <yots...@skymerica.com> wrote:

> The project result is on my GitHub repository
> https://github.com/yotsumoto/casperjs-goto

Looks like an amazing piece of work, and definitely useful cheers!

I'll have a look at the code for sure :)

++

--
Nicolas Perriault
https://nicolas.perriault.net/http://www.akei.com/
Skype: nperriault
Phone: +33 (0) 660 92 08 67

Hiro Yotsumoto

unread,
Aug 23, 2012, 12:16:29 PM8/23/12
to casp...@googlegroups.com
Hi, Nicolas

Thank you for your response and it is my huge pleasure.

I think that then() and checkStep() are very fundamental components of CasperJS.
If you prefer to implement this solution, I'll leave it up to you.

I hope this solution will be implemented to the CasperJS trunk module 
and everyone can get benefit.


Thank you.
Hiro Yotsumoto
 

Jingchao Hu

unread,
Sep 28, 2012, 2:20:20 AM9/28/12
to casp...@googlegroups.com
This is soooooooo awesome work

I have the exactly same problem and having googling a whole day trying to find a solution

thank you for sharing your hack

fard...@gmail.com

unread,
Nov 5, 2013, 6:40:15 PM11/5/13
to casp...@googlegroups.com
Thanks, I've found this quite useful.

As somebody pointed out here, this patch might cause problems with using waitForSelector(), or in my case waitFor(): the "then()" function never gets called. As suggested, a quick workaround is to move the code from the then() function to another block following waitFor().

Reply all
Reply to author
Forward
0 new messages