The SmartBear Community has been improved and moved to new place: community.smartbear.com. All existing user accounts and posts are preserved and migrated as well. You will need just to click "Sign In" button in top right of the page, and then reset your password using your email.

Hope to meet you soon in new community!


How to declare Global variable in TestComplete

#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: 258

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.
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.
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: 258

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.



Like
0
Dislike
This reply answers my question