问题
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
}
Instead of the predicted output of:
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();
I installed casperjs using the latest version of homebrew.
Any help is much appreciated. Thanks in advance.
回答1:
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();
You could try running less sample.js
to verify the contents of sample.js
.
Source
来源:https://stackoverflow.com/questions/21125834/casperjs-trying-to-run-casper-script-from-command-line-doesnt-output-correctl