Posts: 3
Threads: 1
Joined: Mar 2011
Reputation:
0
03-21-2011, 10:25 AM
i want to create a global variable and use it across different action and methods.
I used environment variable but i m not able to do it.
I want to create a Excel application object and used it in different action .
Can you provide me the code or logic.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-21-2011, 11:48 AM
Can you please list out the steps you did to create an environment variable?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-21-2011, 02:48 PM
Two things,
1. I dont understand your objective. What are you trying to achieve? what do you want to store in your environment variable?
2. did you create the environement variable under test settings->Environment->Userdefined?
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Posts: 3
Threads: 1
Joined: Mar 2011
Reputation:
0
03-21-2011, 09:27 PM
My objective is to create a object.suppose i wnt to create a database connection.now i m not going to create database connection every time .so i create one and used it whrever it needed.For that purpose i m trying to create global variable which i create in one script and used it in different functions.
Posts: 1,003
Threads: 1
Joined: Jul 2009
Reputation:
5
03-22-2011, 11:22 AM
If you want to create an object and use it across use it as a function. You can call this function in your various actions.
Here is how environment variable works,
Code:
Under Action 1:
Environment.Value("oStringValue") = "LearnQTP"
In Action 2, Action 3, Action 4..etc etc. you can access this stored value as,
oMyVar = Environment.Value("oStringValue")
msgbox oMyVar ' this will give you LearnQTP which is the value the variable holds.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.