I am using nightwatchJS (Webdriver/Selenium) to test my nodeJS application.
Now I would like to test if a navigation bar is existing and also I want to test if the items of the navBar are as expected.
This is how I tried to get all navigation items. But I don't know how to check the elements. Also I think this is a bit to complicated. Is this the correct way to use nightwatchJS?
module.exports = {
'navigation': function(browser) {
var navElements = []
function getNavElements(elements) {
elements.value.forEach(function(element) {
browser.elementIdText(element.ELEMENT, function(res) {
navElements.push(res.value)
})
})
}
browser
.url(browser.launchUrl)
.waitForElementVisible('#nav', 10000)
browser.expect.element('#nav').to.be.present
browser.elements('css selector', '#nav > .item', getNavElements)
browser.expect(navElements).to.equal(['First', 'Second', 'Third'])
browser.end()
}
}
Aucun commentaire:
Enregistrer un commentaire