Created
September 12, 2012 09:48
-
-
Save wolverian/3705615 to your computer and use it in GitHub Desktop.
CasperJS: passing a function to casper.evaluate() passes undefined instead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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