【发布时间】:2017-01-18 19:15:19
【问题描述】:
我正在使用实习生进行 UI 测试自动化。我有一个测试,输入无效的用户名会导致测试失败。但是,我的测试并没有在应该失败的时候失败。
我想自动化的步骤:
- 输入用户名
- 点击下一步按钮
- 检查是否显示密码文本框(仅当用户名有效时才会显示密码文本框,否则留在同一页面上)
这是我的代码:
页面对象脚本:
enterLoginName: function (username) {
console.log('entering username');
return this.remote
.findById(this.locator.uname).clearValue().sleep(1000)
.type(username)
.end().then(function () {
console.log('username entered ');
})
.findById(this.locator.nextbtn).sleep(1000)
.click().end(); // enter login name and click next button
},
isValidUsername:function() {
console.log('checking if password textbox is displayed');
return this.remote
.findDisplayedById(this.locator.pwd).isDisplayed();
//passowd test box is only shown if username is valid
},
测试脚本:
'correct login name lands to password page': function () {
loginPage.enterLoginName('ss').then(function () {
loginPage.isValidUsername().then(function (pass) {
console.log(pass);
}, function (fail) {
// code reaches here since password test box is not displayed
console.log('user name uas valid , enter password panel not was shown');
assert.fail(0, 1, 'Exception not thrown');// test not failing
});
})
谁能解释一下这里有什么不工作以及如何让它正常工作?
【问题讨论】:
标签: javascript chai intern