casperJS не входит в консоль - PullRequest
       11

casperJS не входит в консоль

6 голосов
/ 24 января 2012

Learning CasperJS

Попытка понять, почему следующее не отображает мои результаты в консоли ....

Выход:

casperjs testcasper.js 

[info] [phantom] Начало ... [info] [phantom] Беговой комплект: 3 шага

код:

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();

1 Ответ

6 голосов
/ 24 января 2012

casper.exit() должен вызываться асинхронно после после всех выполненных шагов;в вашем скрипте это дает:

casper.run(function() {
    console.log(this.getCurrentUrl(),'info'); 
    this.exit();
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...