This question is similar to others, but the problem I had was more basic.
This is my code:
var links = []; var casper = require('casper').create(); function getLinks() { var links = document.querySelectorAll('div#mw-content-text table.wikitable tbody tr td i b a'); return Array.prototype.map.call(links, function(e) { return 'https://en.wikipedia.org' + e.getAttribute('href'); }); } casper.start('https://en.wikipedia.org/wiki/David_Bowie_discography'); casper.then(function() { // aggregate results for the 'casperjs' search links = this.evaluate(getLinks); }); casper.each(links, function (self, link) { self.thenOpen(fullURL, function () { this.echo(this.getTitle() + " - " + link); }); }); casper.run(); I know that links get created as it is copied from the Quickstart, but I then modified it to open all the links that were found.
What I'm getting is that nothing is echo'd instead of outputting the each title which is what I expect. This is how I'm calling the file:
~ $ casperjs casper-google-disco.js