【问题标题】:Why is [object Casper].test undefined?为什么 [object Casper].test 未定义?
【发布时间】:2013-01-01 03:27:06
【问题描述】:

我正在评估 CasperJS 在 Windows 下的测试 API。不幸的是,Casper 对象的 test 属性始终未定义。

运行以下脚本会打印“this.test is undefined”:

phantom.casperPath = 'D:\\GitHubSources\\casperjs';
phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');

var casper = require('casper').create();

casper.start('http://localhost:56679/index.html', function(){
    this.echo('this.test is ' + this.test);
});

casper.run(function(){
    this.exit();
});

有什么提示吗?

【问题讨论】:

    标签: javascript testing integration-testing phantomjs casperjs


    【解决方案1】:

    因为您似乎使用的是 1.1 分支,该分支具有向后不兼容的更改;如in the branch changelog所述:

    如果不使用 casperjs test command 调用 Casper 对象,则不会使用 test 引用创建,因此在不调用它的情况下运行任何测试的能力已被删除。我知道,克服它。

    PS:我实际上正在考虑将master 分支标记为 2.0

    【讨论】:

    • NiKo,你是对的,我不小心使用了 master 分支。适用于标签 1.0.0。感谢您的出色工作!
    猜你喜欢
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    • 2021-07-22
    • 2021-07-18
    • 2012-06-21
    • 2022-01-05
    • 2017-10-10
    相关资源
    最近更新 更多