问题描述
我是casperjs的全新工具,在尝试从命令行运行我的第一个casper脚本(使用 $ casperjs sample.js
)的过程中,我收到此输出:
I'm brand new to casperjs, and in the process of trying to run my first casper script from the command line (using $ casperjs sample.js
), I received this output:
Casper CLI passed args:
[]
Casper CLI passed options:
{
"casper-path": "/usr/local/Cellar/casperjs/1.1-beta2/libexec",
"cli": true
}
而不是预期的输出:
CasperJS, a navigation scripting and testing utility for PhantomJS
PhantomJS: Headless WebKit with JavaScript API
这里是示例文件的内容:
Here are the contents of the sample file:
var casper = require('casper').create();
casper.start('http://casperjs.org/', function() {
this.echo(this.getTitle());
});
casper.thenOpen('http://phantomjs.org', function() {
this.echo(this.getTitle());
});
casper.run();
我使用最新版本的homebrew安装了casperjs。
I installed casperjs using the latest version of homebrew.
任何帮助都非常感激。提前感谢。
Any help is much appreciated. Thanks in advance.
推荐答案
看起来您没有运行您认为您的示例。
It looks like you aren't running the sample that you think you are.
您提供的输出来自此代码:
The output you gave came from this code:
var casper = require("casper").create();
casper.echo("Casper CLI passed args:");
require("utils").dump(casper.cli.args);
casper.echo("Casper CLI passed options:");
require("utils").dump(casper.cli.options);
casper.exit();
您可以尝试运行 less sample.js
以验证 sample.js
的内容。
You could try running less sample.js
to verify the contents of sample.js
.
这篇关于Casperjs - 尝试从命令行运行casper脚本无法正确输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!