Mat*_*ick 3 node.js phantomjs casperjs
所以我有一个在节点中运行的文件,它运行PhantomJS的本地副本,如下所示:
phantom.casperPath = 'node_modules/casperjs';
phantom.injectJs('node_modules/casperjs/bin/bootstrap.js');
var casper = require('casper').create({
viewportSize: config.viewportSize
});
casper.test.begin('Runing tests here', 5, function suite(test) {
// Tests here
});
Run Code Online (Sandbox Code Playgroud)
没有casper.test.begin()我的测试功能很好.我有正确的版本1.1.0,可以使用此测试套件,但我在我的控制台中收到以下错误:
CasperError: casper.test property is only available using the `casperjs test` command
Run Code Online (Sandbox Code Playgroud)
CasperJS文档也提到了这一点:http://docs.casperjs.org/en/latest/testing.html .我的问题是如何在上面的代码中使用此命令运行此Casper,以便我可以使用这些测试?
谢谢!
小智 7
CasperError:casper.test属性仅在
casperjs test命令时可用
问题解决了.
您必须在您的脚本顶部包含此行xyz.js,以便该.test属性变为true;
phantom.casperTest = true;
Run Code Online (Sandbox Code Playgroud)
然后你应该没有问题从终端启动:
casperjs xyz.js
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3170 次 |
| 最近记录: |