How to tell CasperJS to loop through a series of pages
I try to make CasperJS achieve the following: Go through a series of pages that are named sequentially by date. On each page, locate a PDF link. Download the PDF. I got some working code, but I don't understand how CasperJS is going through the sequence of events. For instance, in the code sample below, CasperJS tries to process step 2, and throws a "ReferenceError: Can't find variable: formDate", while step 1 isn't executed at all for some reason. What's wrong with my reasoning? It seems to me that the while loop is executed at a different speed than the casper.then methods. casper.start();