1
我正在使用NightWatchJS编写一些自动化功能。我有我哪里以下的东西登录后无法找到元素
- 打开网址
- 登录
- 验证元素
- 验证IFRAME元素
我有一个提交按钮简单的登录页面一个简单的测试场景。内部页面在登录后也具有iframe。只要登录操作成功,iframe中的文本字段就会用javascript进行关注。
我NightWatch测试代码
module.exports = {
before: function(browser) {
console.log("Setting up...");
browser
.maximizeWindow()
},
after : function(browser) {
browser
.end()
console.log("Closing down...");
},
'Check Form Elements' : function (browser) {
browser
.url("siteurl")
.waitForElementVisible("body", 1000)
.waitForElementPresent('#email', 10000)
.setValue('#email','[email protected]')
.waitForElementPresent('#password', 10000)
.setValue('#password', 'encrypted')
.submitForm('#login_form', function(result){
console.log(result)
})
.pause(5000)
.waitForElementVisible('body', 10000)
.waitForElementVisible('li.active', 5000)
.assert.containsText('li.active', "Home")
.assert.elementPresent('#iframeone')
.frame('iframeone')
.waitForElementVisible('.wi-wrap', 5000)
. assert.containsText('header h1', 'Messages')
}
};
该测试通过,直到表单提交失败说
Timed out while waiting for element <body> to be present for 10000 milliseconds. - expected "visible" but got: not found
我使用Chrome 50,ChromeDriver 2.21.371459,OS X
之后 - 埃尔卡皮坦。 我在下面附上我的硒细节。
在此先感谢。
嘿宝,登录没有任何问题。我可以看到页面中呈现的所有元素,但测试失败,因为它从来没有找到这样的元素。 – a5his
所以你可以为waitForElementVisible添加一个参数,并用验证替换assert。测试不会崩溃,所以我们可以看到哪个元素出错了,哪个出现了错误。 –
我点击后通过添加'.waitForElementVisible('body',5000,false)''在测试代码中做了lil更改,它永远不会找到主体。 – a5his