Casperjs - 尝试从命令行运行casper脚本无法正确输出 [英] Casperjs - trying to run casper script from command line doesn't output correctly

查看:822
本文介绍了Casperjs - 尝试从命令行运行casper脚本无法正确输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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脚本无法正确输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆