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();
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();
Share
Improve this question
asked Jan 24, 2012 at 15:46
CmagCmag
15.8k25 gold badges97 silver badges147 bronze badges
1
- Is this issue with scope? :( Same code runs fine outside of function – Cmag Commented Jan 24, 2012 at 16:30
1 Answer
Reset to default 6casper.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();
});