nightwatch
Version:
Easy to use Node.js based end-to-end testing solution for web applications using the W3C WebDriver API.
47 lines (44 loc) • 1.12 kB
JavaScript
const util = require('util');
const menuXpath = '//div[contains(@class, "hdtb-mitem")][contains(., "%s")]';
const menuCommands = {
productIsSelected: function (product, callback) {
var self = this;
return this.getAttribute(product, 'class', function (result) {
let isSelected = result.value.indexOf('hdtb-msel') > -1;
callback.call(self, isSelected);
});
}
};
module.exports = {
elements: {
results: {selector: '#rso'}
},
sections: {
menu: {
selector: '#hdtb-msb',
commands: [menuCommands],
elements: {
all: {
selector: util.format(menuXpath, 'All'),
locateStrategy: 'xpath',
index: 0
},
video: {
selector: util.format(menuXpath, 'Videos'),
locateStrategy: 'xpath',
index: 0
},
images: {
selector: util.format(menuXpath, 'Images'),
locateStrategy: 'xpath',
index: 0
},
news: {
selector: util.format(menuXpath, 'News'),
locateStrategy: 'xpath',
index: 0
}
}
}
}
};