Forum Discussion
Correct that seems to have done it.
My next question, is why isn't other classes able to see these functions? The Code below works. However when exporting the class to another, it doesn't know what UserPrefs is
var Header = undefined; var Main = { UserPrefs: function() { Header.menuMain.HoverMouse(); return Header.menuMain_UserPrefs; } } function foo() { Header = Aliases.browsers.pageDashboard_PhysOffice; Main.UserPrefs().Click(); }
Navigation.cs
var Menu = require("Menu"); function foo() { Menu.Header = Aliases.browser.pageDashboard_PhysOffice; Menu.Main.UserPrefs().Click(); }
We have a header at the top of almost every page, I am trying to make a common class which all pages can reference when trying to navigate.
Menu.Parent.Child.Click(); is what I am trying to create. Then I would create a single class which handles Navigation.
Novari-QA wrote:
Correct that seems to have done it.
My next question, is why isn't other classes able to see these functions? The Code below works. However when exporting the class to another, it doesn't know what UserPrefs isvar Header = undefined; var Main = { UserPrefs: function() { Header.menuMain.HoverMouse(); return Header.menuMain_UserPrefs; } } function foo() { Header = Aliases.browsers.pageDashboard_PhysOffice; Main.UserPrefs().Click(); }
Navigation.cs
var Menu = require("Menu"); function foo() { Menu.Header = Aliases.browser.pageDashboard_PhysOffice; Menu.Main.UserPrefs().Click(); }
We have a header at the top of almost every page, I am trying to make a common class which all pages can reference when trying to navigate.
Menu.Parent.Child.Click(); is what I am trying to create. Then I would create a single class which handles Navigation.
It depends upon how you are doing the modules.export and the requires calls. I have a "toy" project that I use to explore creating custom JavaScript classes and have them called across code units and, when implementing such a thing in TestComplete, there were some "hoops" I needed to jump through to get it to work properly.
Could you share the entire code units, complete with the exports calls and such?
- Novari-QA7 years agoFrequent Contributor
Certainly
Foo function works, where abc function do not. - Novari-QA7 years agoFrequent Contributor
a
- tristaanogre7 years agoEsteemed Contributor
The import functions feature of TestComplete does not do the necessary tasks for JavaScript. In test, you need to add
module.exports = Test
at the end of the code unit that has the class you want to export. You can then instantiate and use that class in any unit that has
var Test = requires("Test")
in the beginning.
Related Content
Recent Discussions
- 3 hours agoSvetaG