【发布时间】:2014-05-07 14:06:46
【问题描述】:
我想测试 mns.core 的值是在 CasperJS 中设置的。我尝试了以下方法:
casper.test.begin('Upholstery contains stuff', 3, function (test) {
casper.start('http://127.0.0.1/layouts/en_gb/page-upholstery.php', function () {
var mns = this.evaluate(function(){
return mns;
});
console.log(typeof mns.core);
test.assert(typeof mns.core == "object","mns has properties");
});
casper.run(function() {
test.done();
});
});
mns 在 casperJS 中被设置为一个对象,当通过浏览器加载时,mns.core 是一个对象,但是它未能通过此测试,因为它显示为未定义。
【问题讨论】:
-
也许你可以直接在 Casper 中使用 utils 模块:Casper Utils,还有一些有用的功能,如
isType()、isObject()等... -
谢谢,Casper Utils 看起来会派上用场,但下面也解决了我的问题 :)
标签: testing phantomjs casperjs