Forum Discussion
Hi,
USEUNIT methods to access function in one script unit from another script unit.
Declare Global Variables which can be accessed through the scripts
There are numerous ways you can do it.
Pass it as a parameter. - https://support.smartbear.com/testcomplete/docs/testing-with/parameterizing/script-routines.html
Use a Python Global variable. - http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them (Be careful if you use Python globals. If you don't make it obvious something is a global variable, it can get VERY confusing for someone trying to debug or alter your code in future. I also don't know how Python Globals behave between TC script units)
Use a project level TC variable. - https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/index.html
Use a temp file. Python provides this natively as well normally, but again, not sure about within TC. - https://docs.python.org/2/library/tempfile.html
- tristaanogre9 years agoEsteemed Contributor
karthick7 USEUNIT I don't think is supported for Python in TestComplete. You need to use import <unit> * or from <unit> import.
If you do import <unit> * or from <unit> import * and you declare your variables globally in the unit, you should be able to get to your variables directly. Again, as with the other thread you started, reference https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/declared-in-another-unit/python.html