12-07-2012, 08:59 PM
An external environment variable file can either be a xml file or an ini file.
I would suggest you to use ini as it is easy to maintain. If you want to use xml, read QTP help or google it.
Just create a text file with extension as ".ini". E.g.: "Environment.ini"
In the beginning of the file, add [Environment]
Following that, you can specify the variables and their values... it will look some thing like this...
---
[Environment]
---
To use this file, you have to import it to your script.
Use Environment.Loadfromfile("Path of your environment file")
Eg:
Now you can use it whenever you want.
For example, if you like to open google,
or
Value is the default property of environment, you can use
Hope this helps.
Thanks,
Elango
I would suggest you to use ini as it is easy to maintain. If you want to use xml, read QTP help or google it.
Just create a text file with extension as ".ini". E.g.: "Environment.ini"
In the beginning of the file, add [Environment]
Following that, you can specify the variables and their values... it will look some thing like this...
---
[Environment]
Code:
mybrowser = "www.google.com"
Firstname = "diya"
Lastname = "lastname"
To use this file, you have to import it to your script.
Use Environment.Loadfromfile("Path of your environment file")
Eg:
Code:
Environment.Loadfromfile("C:\Environment.ini")
Now you can use it whenever you want.
For example, if you like to open google,
Code:
SystemUtil.Run "iexplore.exe", Environment.Value("mybrowser")
Value is the default property of environment, you can use
Code:
SystemUtil.Run "iexplore.exe", Environment("mybrowser")
Hope this helps.
Thanks,
Elango