How to declare Global variable in TestComplete

Subscribe to this thread
Feed for this thread Post Reply
#1
How to declare Global variable in TestComplete
Posted on 16 Mar 2011, 08:55 AM
Gopal Malu User avatar
Member
Member
Posts: 21
Reputation: 16
HI,

We want to use global variable which can be accessible throughtout the function (test).
How can we do this in testcomplete?

Thanks,
Gopal
Like
Dislike
This reply answers my question
#2
RE: How to declare Global variable in TestComplete
Posted on 16 Mar 2011, 10:22 AM
David User avatar
Staff
Posts: 1661
Reputation: 238

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.

Vote for this reply
Like
0
Dislike
This reply answers my question
#3
RE: How to declare Global variable in TestComplete
Posted on 22 Mar 2012, 05:35 AM
Andrey Simonov User avatar
Member
Member
Posts: 4
Reputation: 2
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.

Vote for this reply
Like
0
Dislike
This reply answers my question
#4
RE: How to declare Global variable in TestComplete
Posted on 22 Mar 2012, 07:32 AM
David User avatar
Staff
Posts: 1661
Reputation: 238

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.




Vote for this reply
Like
0
Dislike
This reply answers my question
Post Reply