Skip to content

Instantly share code, notes, and snippets.

@wolverian
Created September 12, 2012 09:48
Show Gist options
  • Save wolverian/3705615 to your computer and use it in GitHub Desktop.
Save wolverian/3705615 to your computer and use it in GitHub Desktop.
CasperJS: passing a function to casper.evaluate() passes undefined instead
var casper = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casper.start('http://www.google.com', function() {
console.log('opened page');
this.on('page.error', function(msg, backtrace) {
this.echo("Error: " + msg, "ERROR");
});
this.evaluate(function(s, n, f) {
console.log('entered browser context');
console.log(s); // works
console.log(n); // works
f(); // fails
console.log('leaving browser context'); // we never reach this line
}, {
s: "bar",
n: 42,
f: function() {
console.log("*** SUCCESS ***");
}
});
});
casper.run(function() {
this.exit();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment