Reply
Contributor
Posts: 21
Registered: ‎02-01-2011

How to declare Global variable in TestComplete

HI,



We want to use global variable which can be accessible throughtout the function (test).

How can we do this in testcomplete?



Thanks,

Gopal
Staff
Posts: 1,545
Registered: ‎01-28-2014

RE: How to declare Global variable in TestComplete


Hi Gopal,





You can use project and project suite variables.





Also, you can declare a variable in the script unit outside all functions - in this case, the variable will have a global scope.
--
Best regards,
Dmitry
New Contributor
Posts: 4
Registered: ‎02-21-2012

RE: How to declare Global variable in TestComplete

Hello,



Are non-project global variables visible across different scripts?



I've created a global scope variable in one script,



Dim testVar : testVar = "test"



However, the following sub in another script does not see the variable:



Sub CheckVar

Log.Message testVar

End Sub



I've set up the project in such a way, that it runs CheckVar at start.
Staff
Posts: 1,545
Registered: ‎01-28-2014

RE: How to declare Global variable in TestComplete


Hello Andrey,



It looks like you are talking about two script units. In order to call variables declared in another unit, you need to add the USEUNIT directive to the calling unit. For more information, refer to the Calling Routines and Variables Declared in Another Unit help topic.







--
Best regards,
Dmitry