I am currently working with node + nightwatch + selenium for automation. I came across a scenario:
I have defined an array as Global array in nightwatch:
Dev.js
'checkforLink':{
link1:"Some Xpath 1",
link1:"Some Xpath 2",
link1:"Some Xpath 3",
link1:"Some Xpath 4"
},
In my custom js script in custom-commands, I am doing a for
loop to fetch this links from global variable:
exports.command = function(callback) {
browser = this;
var data = browser.globals;
console.log("Before all loop");
for(var menu_link in data.checkforLink) {
linkss1 = data.checkforLink.link1; // returns `Some Xpath 1`
reqvar = data.mainMenuLink.menu_link; // Even though menu_link have value as link1, reqvar is undefined
browser.click('######') // Click the path
}
return this;
};