I'm trying to nest casper.then() actions in a while loop. However, It seems that the script never executes the code inside those casper.then() functions.
Here's my code
casper.then(function() {
while (this.exists(x('//a[text()="Page suivante"]'))) {
this.then(function() {
this.click(x('//a[text()="Page suivante"]'))
});
this.then(function() {
infos = this.evaluate(getInfos);
});
this.then(function() {
infos.map(printFile);
fs.write(myfile, "\n", 'a');
});
}
});
Am I missing something ?