admin管理员组文章数量:1391968
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();
});
本文标签: javascriptcasperJS not logging to consoleStack Overflow
版权声明:本文标题:javascript - casperJS not logging to console - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669658a2618748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论