Environment Variables, QTP examples for environment variables, Types of Environment Variable



Environment Variables , QTP examples for environment variables, Types of Environment Variable

Global variables and Environment Variables in QTP are the just like similar because both can be accessed from the any section of the script. These variable proves very beneficial when you like a variable need to shared from one script to another script and can be reused with functions and actions.

Following are the Two types of Environment Variable:-
  1. Built in Variables
  2. User Defined Variables
    - Internal
    - External

Built in Variable:
These types of variables always shows the information related to the testing which test can run, like as operating system and Test path. Plus point – these variables can be access from all the test scripts and designated as read only.

Syntax will be -:
Variable = Environment(“Name of Environment Variable”)

Example -:
'Few In built Environment Variables are given below
 
Msgbox Environment("OS")
Msgbox Environment("OSVersion")
Msgbox Environment.value("ProductDir1")
Msgbox Environment.value("ProductName2")
 
'Following is the path where Test result for the current test will be saved
Msgbox Environment("ResultDir1")

Internal User Defined Variable:
It also called User Defined Internal -: These variables defined inside the test script. 
These variable can be saved with the test script and can be access only from the test script.
Example:
'We can declare the own variable as if “Url1”
Environment.Value(“Url1”) = “http:\\www.yahoo.com”
URL = Environment.Value(“Url1”)
Systemutil.Run “firefox.exe”, URL


External User Defined Variable:
User defined external environment variable -: There are the predefine variables in any active external environment variable file. 
Actually these variable declare with the help of a list of variables values pair in any external file of .xml format.
Following are the steps which are required to follow:
Create External User Defined Variable:
File → Settings → Environment → Variable types need to be choose as user defined  → Now Click on icon named Add(+) → 
Now input the name of variable and Then value → Click OK and Then Click on Export → Now just browse the path and input the name of file 
→ Save with XML extension → Finally Ok clicked
Associate Environment Variable file (XML Format):
File →  Settings → Environment →  Select variable type as user defined →  check “load variables and values from the external file” → 
browse path of the xml file →  click apply →  Click OK.

XML file with variable name and value should be mentioned ........
 





Advantages and Disadvantages of Automation Testing













Virtual Objects with Example in QTP
Cross Platform Testing


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



Test Automation Frameworks Types



No comments:

Post a Comment

Popular Posts