【发布时间】:2019-06-17 09:06:01
【问题描述】:
在我的测试中,我需要在多个页面上验证相同的文本行。
我正在尝试使用 chai 断言,但无法使用页面对象运行多个 .expept 断言。
有两个 '.expect' 断言使测试失败并显示错误消息
Unknown property: "expect". Please consult docs at:http://nightwatchjs.org/api.
当我只用一个命令运行它时,它运行正常。
// Test file code
module.exports = {
'Copy Test': client => {
client.url('https://www.testsite.com/')
client.page.search().checkText()
client.end();
},
};
// Page object file code
let copyP = "Some test text"
let copyP2 = "Some text text 2"
module.exports = {
elements: {
p: 'CSS_selector',
p2: 'CSS_selector',
},
commands: [{
checkText: function() {
return this
.expect.element('@p').text.to.equal( copyP, 'Text is ok')
.expect.element('@p2').text.to.equal( copyP2, 'Text2 is ok')
}
}]
}
【问题讨论】:
标签: automation ui-automation nightwatch.js assertion pageobjects