What are the Available Environment Variable Types With Examples, Environment Variables in QTP



What are the Available Environment Variable Types With Examples, Environment Variables in QTP

What are the types of environment variables in QTP ?
Environment Variables in QTP quite same as like global variables that can be used through any part of the script. Actually These variables are very useful when you would like to variable to be divided across multiple re-usable function and actions.

There are mainly Three types of Environment Variables in QTP:
  1. Built in (Its Read Only)
  2. User Defined Internal (Read Only Also)
  3. User Defined External (Read / Write only)

EXAMPLE:- Following syntax can be used to set the Environment Variable:

Environment.Value(“Name1”) = “Mytest”

Using following Syntax Environment Variable values can be retrieve:

Environment.Value(“Name1”) – It will populate return the name as Mytest
Environment.Value(“OS”) – It will return our system OS

Built in Variable: These variables generally shows the info about the test script where the test script required to run. Like Operating system and Test path. These variables are permissible from all test scripts scenarios and designated as a read only.

Syntax:

Variable = Environment("environment variables myname")

Example:
'Following are the In built Environment Variables
 
Msgbox Environment("OS1")
Msgbox Environment("OSVersion1")
Msgbox Environment.value("ProductDir1")
Msgbox Environment.value("ProductName1")
 
'path where Tests Script result for the current test is saved 
Msgbox Environment("ResultDir1")
Internal User Defined Variables:

These types of variables commonly define within the test script. These variables are saved with tests script and permissible only with in the tests script.

Example:
'You can create their own environment variable as "Url"
 
Environment.Value("Url1")= "http:\\www.yahoo.com" 
 
URL1=Environment.Value("Url1")
 
Systemutil.Run "firefox.exe",URL1
External User Defined Variable:

External User Defined: Such variables which are already defined in the enable external environment variable file. These can be generated with the help of a list of variable values pair in an outer file in the format of .xml;

Steps How to create External User Defined Variable:
File – Settings – Environment – Select the type of variable like user defined – Just click on Add icon (+) - Now just enter the value and name of variable – Click on OK – Click Export – Now just browse the path and then enter the name of file – Now save this xml file which have the extension .xml – click on OK

Associate Environment variable File (xml):

File – settings – Environment – select the variables types as like user defined – Check “values from the external files and load variable” – Now browse the xml file path – Click Apply – Click on OK

CML files with the name of variable and value of variable should be described or mentioned …..

What are the Available Environment Variable Types With Examples
What are the Available Environment Variable Types With Examples


















Virtual Objects with Example in QTP
Cross Platform Testing


What is Object Spy in QTP Ordinal Identifiers Alone can Make an Object Unique








No comments:

Post a Comment

Popular Posts