Learning CasperJS
Trying to understand why the following is not displaying my results in the console....
output:
casperjs testcasper.js
[info] [phantom] Starting... [info] [phantom] Running suite: 3 steps
code:
var casper = require('casper').create({
loadImages: true,
loadPlugins: true,
verbose: true,
logLevel: 'debug',
});
casper.start(url, function() {
this.debugPage();
this.echo("Test echo.");
this.fill('form#LogonForm', {
'username': username,
'password': password,
}, true);
});
casper.then(function() {
casper.echo("I'm loaded.");
});
casper.run(function() {
console.log(this.getCurrentUrl(),'info');
});
//casper.log('this is a debug message', 'debug');
//casper.log('and an informative one', 'info');
//casper.log('and a warning', 'warning');
//casper.log('and an error', 'error');
casper.exit();
casper.exit()
must be called asynchronously after all the steps having been executed; in your script, this gives:
casper.run(function() {
console.log(this.getCurrentUrl(),'info');
this.exit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With