I'm using CasperJS to automate a series of clicks, completed forms, parsing data, etc through a website.
Casper seems to be organized into a list of preset steps in the form of then
statements (see their example here: http://casperjs.org/quickstart.html) but it's unclear what triggers the next statement to actually run.
For example, does then
wait for all pending requests to complete? Does injectJS
count as a pending request? What happens if I have a then
statement nested - chained to the end of an open
statement?
casper.thenOpen('http://example.com/list', function(){
casper.page.injectJs('/libs/jquery.js');
casper.evaluate(function(){
var id = jQuery("span:contains('"+itemName+"')").closest("tr").find("input:first").val();
casper.open("http://example.com/show/"+id); //what if 'then' was added here?
});
});
casper.then(function(){
//parse the 'show' page
});
I'm looking for a technical explanation of how the flow works in CasperJS. My specific problem is that my last then
statement (above) runs before my casper.open
statement & I don't know why.