Global Variable In Nightwatch. Issue In For Loop For Node.js
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':{
Solution 1:
When you run for(var menu_link in data.checkforLink)
, the variable 'menu_link' will be a string.
To get the property from an object with a string use 'object[string]' syntax. Try data.mainMenuLink[menu_link];
This should work as long as data.mainMenuLink.link1 exists.
I noticed in your question all of the properties have the value 'link1'. Hopefully they are different property names in your code.
Solution 2:
I am not sure your actual problem is related to loop only or you are not able to create a instance using "var data = browser.globals;" so your variable data having {} no value.If this is a case please rename your Dev.js as "globals.js" and provide a path of it as value of a key "globals_path" in "nightwatch.json".
Post a Comment for "Global Variable In Nightwatch. Issue In For Loop For Node.js"