Forum Discussion
- HKosovaSmartBear Alumni (Retired)Hi Praveen,
You can declare the variable as a project or project suite variable. In this way, you'll be able to use the variable across all tests in your project or project suite. - praveensqaContributorThanking you.
Yes. But i have the scenario like this
Unit is Te2
'USEUNIT Te3
Sub pro
dim va
Va=10
End Sub
Unit is Te3
'USEUNIT Te2
Function Te3
Te2.pro// for calling Te2 Pro--- Fine.
\\ Here i need to get the Va variable value from unit Te2
if i type Te2.Va--- Ok, but while execute the test i am getting object doesn't support the Exception is coming.
How i will get Va value in this unit. is there any method?
End Function
Regards,
Praveen - HKosovaSmartBear Alumni (Retired)Hi Praveen,
To access the Va variable defined in the Te2 unit using the Te2.Va syntax, you need to define this variable outside of any routines, so that it has the global scope (rather than the local scope to the pro routine):Dim Va
Sub pro
Va = 10
End Sub
Alternatively, you can create the Va variable as a project variable (in Tools > Current Project Properties > Variables); in this case, you can use this variable like this:
Unit Te2:'USEUNIT Te3
Sub pro
Project.Variables.Va = 10
End Sub
Unit Te3:'USEUNIT Te2
Function Te3
Te2.pro
Log.Message Project.Variables.Va
End Function - praveensqaContributorThanking You Helen Kosova. It is very use full to me. Now i am able to access that Variable in all the Units.
- andr_simonovNew ContributorHello,
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. - AlexKarasChampion Level 3Hi Andrey,
Have you referenced (via 'USEUNIT Unit1) the first script unit from the second one (http://support.smartbear.com/viewarticle/11452/)? - HKosovaSmartBear Alumni (Retired)Hi Andrey,
Please see David's reply to your question in this thread:
How to declare Global variable in TestComplete
Also, please refrain from posting duplicate questions in different forum threads as it makes it confusing to give consistent answers. Thanks!
Related Content
- 5 years ago
- 3 years ago
Recent Discussions
- 8 hours ago