Multiple start / run chains?

676 views
Skip to first unread message

Andrew Ray

unread,
Nov 8, 2012, 11:42:17 PM11/8/12
to casp...@googlegroups.com
I am attempting to do something like this:

casper.start('someUrl')
casper.evaluate(something);
casper.run();

casper.thenOpen('someOtherUrl')
capser.run();

When I try to do the above it seems like the second group of steps is ignored.

I am attempting to drive casper / phantom / spookyjs and running into a bit of a catch 22. I would like my test suite to drive casper, as in once one test finishes start the next one which contains casperjs commands.

Basically I want to be able to issue commands to casper whenever I want. It's very constricting to be forced into one linear model that you set up, call, and then you're dead forever. It doesn't make sense to me. Phantom doesn't work this way, does it? Is there a way so that I can just call casperjs commands on the fly? What is the reasoning behind having a big queue that you call with run? why not just execute commands as they come in?

Nicolas Perriault

unread,
Nov 9, 2012, 4:23:01 AM11/9/12
to casp...@googlegroups.com
On Fri, Nov 9, 2012 at 5:42 AM, Andrew Ray <delva...@gmail.com> wrote:

> I am attempting to do something like this:
>
> casper.start('someUrl')
> casper.evaluate(something);
> casper.run();

Try thenEvaluate() instead

> I am attempting to drive casper / phantom / spookyjs and running into a bit
> of a catch 22. I would like my test suite to drive casper, as in once one
> test finishes start the next one which contains casperjs commands.

Have a look at this sample
https://github.com/n1k0/casperjs/blob/master/samples/dynamic.js

> Basically I want to be able to issue commands to casper whenever I want.
> It's very constricting to be forced into one linear model that you set up,
> call, and then you're dead forever.

You're not "dead forever", see the sample pasted above. By cons having a
stack of navigation steps is basically useful to predictably run and
wait for things.

++

--
Nicolas Perriault
https://nicolas.perriault.net/
Phone: +33 (0) 660 92 08 67
Reply all
Reply to author
Forward
0 new messages