所以我相信通过文档查看这应该可以正常工作,但我希望运行一个预期已经完成的东西,但是目前它似乎没有工作。
工作
browser
.url('https://www.google.co.uk/?')
.expect.element('.Google Search').value.to.contain('Dashboard')
.perform(function() {
console.log('elementValue');
})
断
browser
.url('https://www.google.co.uk/?')
.expect.element('.Google Search').value.to.contain('Dashboard')
.perform(function() {
console.log('elementValue');
})
Error while running perform command: browser.moveToElement(...).doubleClick(...).setValue(...).click(...).expect.element(...).text.to.contain(...).perform is not a function
答案 0 :(得分:2)
当你使用.expect
时,你打破了Nightwatch命令链并启动了Expect.js链,所以在你调用.expect.element('.Google Search')
之后你得到的是Expect.js对象,而不是Nightwatch browser
对象。
你需要的是简单地开始另一个链:
browser
.url('https://www.google.co.uk/?')
.expect.element('.Google Search').value.to.contain('Dashboard');
browser
.perform(function() {
console.log('elementValue');
});