我想在我的夜班测试中实现页面对象模式,并同时使用mocha。
我的测试类看起来像这样
module.exports = {
'Create Subscription' : function (browser) {
var createPage= browser.page.createSubscriptionPage();
var subscriptionName = '_test_nightWatch',
subscriptionDescription = 'description';
it('should create a subscription', function(browser){
createPage.navigate()
.waitForElementVisible('@nameField', 20000)
.setValue('@nameField', subscriptionName)
.setValue('@descriptionField', subscriptionDescription)
.expect.element('@nameField').to.have.value.that.equals(subscriptionName)
browser.expect.element('@descriptionField').to.have.value.that.equals(subscriptionDescription)
browser.end();
});
}
};
我将我的json文件更新为
"test_runner" : {
"type" : "mocha",
"options" : {
"ui" : "bdd",
"reporter" : "list"
}
}
它启动服务器但没有运行
我在网上看过这个问题,但没有一个已经解决了
答案 0 :(得分:1)
想出来......
var expect = require('chai').expect;
var nightwatch = require('nightwatch');
describe('Create Subscription', function() {
var subscriptionName = '_test_nightWatch',
subscriptionDescription = 'description';
it('should create a subscription', function(browser){
var createPage= browser.page.createSubscriptionPage();
createPage.navigate()
.waitForElementVisible('@nameField', 20000)
.setValue('@nameField', subscriptionName)
.setValue('@descriptionField', subscriptionDescription)
.expect.element('@nameField').to.have.value.that.equals(subscriptionName)
browser.end();
});
});
编辑:正确格式化文字