GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  QTP
Go To First  |  Previous Question  |  Next Question 
 QTP  |  Question 661 of 674    Print  
Environment Variables
How to load environment variables during runtime?


  
Total Answers and Comments: 3 Last Update: July 13, 2009     Asked by: sagirinaveen 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: raghuramgupta
 
In the runtime to load the environment variables we can use the statement
Environment.LoadFromFile("C:Atlas.Net.QA2.0ATPFrameWorkCommonEnvironmentVariables.xml")

Above answer was rated as good by the following members:
atchi
June 20, 2009 03:13:57   #1  
ram4u Member Since: February 2009   Contribution: 2    

RE: Environment Variables

User-Defined Internal User-Defined External Built-in are the types of environment variables available in QTP.

Built-in variables as the name suggests are predefined by QTP. Examples of such variables are OS OSVersion ActionName which are for Operating System Operating System Version and name of the action which is currently running respectively.

Lets look at an example of this:

1. Open a new Test.

2.Go to File (Menu)->Settings a Test Settings window opens.

3. Go to Environment Tab. By default Built-in variable type is selected and you will be able to see Name and Description of Built-in variables below Variable type dropdown box.

4. You can click on any of those variables to see their current value.

5. I just did the above four steps in order to show you from where you can access Built-in variables.

6. Now close this Test Settings window and go to test.

7. In the Expert View type:

a environment("ActionName") & " is running on " & environment("OS")
msgbox (a)

8. And Run the test.

It is just a simple way to show how a Built-in environment variable works.

User Defined Internal variables are the variables defined by you (the user) within the test and which are saved within the test and also accessible from within the test.

Lets look at an example of this:

1. Open a new Test.

2. Go to File (Menu)->Settings a Test Settings window opens.

3. Go to Environment Tab. From Variable type dropdown select User-defined.

4. Click on the '+' which is on the right of Variable type dropdown.

5. 'Add New Environment Parameter' window opens up type the name and value of the variable e.g. in Name type 'a' and in Value type 'hello' (without quotes I have added quotes just for clarity) and click on OK. It will add the variable with its type as 'internal'.

6. Click Apply and OK to come out of Test Settings window.

7. Go to expert view and type:
msgbox(environment("a"))

8. Now Run the test. It will show you the value of variable 'a' in the message box.

User-Defined external variables are the variables which are defined in the file outside of test. These act as read only for the test. You can create as many files for environment variables as you want and choose them for your test.

Now lets look at an example of this:

Open a new text file and type the following lines in it and save it with .xml extension. ( I saved it in 'tests' folder in the 'QuickTest Professional' folder under C:Program files.)

1. Open a new Test.

2. Go to File (Menu)->Settings a Test Settingswindow opens.

3. Go to Environment Tab. From Variable type dropdown select User-defined.

4. Click on "Load variables and values from external file" check box and import that external xml file that we created above. As soon as it is imported the complete path of that file will be shown in the File text box and the variable in it will show under Name Value and Type heading (in our case it will show Address under Name 25 yellow Road under Value and External under Type).

5. Click on Apply and Ok to come out of it.

6. Go to expert view and type:
msgbox(environment("Address"))

7. Now run the test. It will show you the value of variable 'Address' in the message box.


 
Is this answer useful? Yes | No
June 22, 2009 09:54:59   #2  
sandy1300 Member Since: June 2009   Contribution: 2    

RE: Environment Variables
Yes you can call you have an option called call to copy of an action with that you can use.
 
Is this answer useful? Yes | No
July 13, 2009 05:28:11   #3  
raghuramgupta Member Since: January 2007   Contribution: 26    

RE: Environment Variables
In the runtime to load the environment variables we can use the statement
Environment.LoadFromFile("C:Atlas.Net.QA2.0ATPFrameWorkCommonEnvironmentVariables.xml")

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape