I need to run 3 url requests simultaneously.I thought of running 3 casper instances each fetching a url. As a simple example,I tried with 2 instances.
var casper=require('casper').create();
casper.start('http://www.google.com');
var casper1=require('casper').create();
casper1.start('http://www.google.com');
casper1.then(function() {
casper1.echo('inside');
});
casper1.echo('outside');
casper1.run();
casper.run();
Output shows only 'outside'.Why does'nt it run the casper1.echo('inside');
CasperJS uses a stack of commands that created whenever you use one of the functions from their api (start, then, thenOpen, etc). Once all of the items are queued up in the stack, you can execute them in order by doing casper.run(). If something isn't added to the stack, Casper will not execute it.
Simply put, casper1.echo('outside') isn't being executed because it was never added to the stack.
Their FAQ on the topic breaks it down in more detail.