文档并没有真正有用——太简短和模糊。正如我从文档中了解到的那样,我们只需要在测试目录上运行 casperjs 命令并确保每个测试都以Tester.done()
. 这是我的两个测试,
//test1.js
var casper = require('casper').create();
var urlPrefix = "http://localhost/NavHawk2/";
casper.start(urlPrefix , function() {
this.test.assertSelectorHasText('title', 'Login', 'Title Ok! Login Page Expected');
this.test.assertExists('form[action$="/login"]', 'Login Form is found');
this.fill('form[action$="/login"]', {
.....
}, true);
});
casper.run(function() {
this.test.done(2);
});
//test2.js
var blinkingCircleImg = "7.gif"
casper.on('page.error', function(){
console.log("SOme Javascript error persists!");
});
casper.then(function(){
this.test.assertSelectorHasText('title', 'Map', 'Login Ok! Map Page Expected');
this.test.assertExists('img[src$="' + blinkingCircleImg + '"]', 'Blinking Circle being shown!');
this.test.assetNotVisible('#sidebar_content_geofences', 'Geofencing sidebar not being shown!');
});
casper.run(function() {
this.test.renderResults(true);
this.test.done(3);
});
问题是该test2.js
文件永远不会运行。也许我在某个地方错了。