· Data table Method.
· Environment Variable.
· Random Numbers.
33.1. Environmental Variable:
When we want to use the same variable in different actions then we can use envionment variables we can load the set of environment variables from a XML file directly
33.1.1. Types of Environmental Variable:
· User-Defined Internal.
· User-Defined External.
· Built-in.
a. Build-In Variables:
Build-in variables are the name suggests are predefined by QTP. Examples of such variables are OS, OS Version, ActionName which are for Operating System, Operating System Version and Name of the action which is currently running, respectively.
Step 1: Open a new test.
Step 2: Go to the File (Menu)>Settings, a Test settings window opens.
Step 3: Go to the Environment Tab. By default Built-in variable type is selected and you will be able to see Name and Description of the Build-in variables below variable type Dropdown box.
Step 4: You can click on any of those variables to see their current value.
Step 5: Now close the Test Settings window and go to test.
Step 6: In the Expert view type:
a=Environment (“actionname”) & “is running on” & environment (“OS”)
msgbox (a)
Step 7: Run the Test.
b. User Defined Internal:
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.
Step 1: Open a new test.
Step 2: Go to File menu> Settings, a Test Settings window opens.
Step 3: Go the Environment Tab. From Variable Type dropdown select User- Defined.
Step 4: Click on the ‘+’ which is on the right of Variable Type dropdown.
Step 5: Add New Environment Parameter’ window opens up, type the Name and Value of the Variable e.g. in Name type ‘Agentname’ and in Value type ‘arcus’ (without quotes, I have added quotes just for clarity) and click on OK. It will add the variable with its type as ‘internal’.
Step 6: Click Apply and OK to come out of the Test Settings window.
Step 7: Open the Test in QTP, and Enter the script as
E.g.: lv_agentname=Environment.Value ("agentname")
lv_password=Environment.Value ("password")
systemutil.Run"C:\Program Files\Mercury Interactive\QuickTest
Professional\samples\flight\app\flight4a.exe"
Dialog ("Login").WinEdit ("Agent Name :") .Set lv_agentname
Dialog ("Login").WinEdit ("Password :") .Set lv_password
Dialog ("Login").WinButton ("Cancel").Click
Step 8: Execute the Script and analyse the Result.
c. User Defined External:
User Defined External Avriables 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.
Step 1: Open a new NotePad .
Step 2: Enter the Value as
And save this notepad as .xml file.
Step 3: Open the New Test in the QTP.
Step 4: Go to File menu> Settings, a Test Settings window opens.
Step 5: Go the Environment Tab. From Variable Type dropdown select User- Defined.
Step 6: Click on “load Variables and values from external file “ check box and import the 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 variables in it will show under Name, Value and Type heading (in our case it will show Agentname under Name, arcus under Value, and External under Type).
Step 7: Click on Apply and Ok to come out of it.
Step 8: Open the test in the QTP, and type Script as
Environment.LoadFromFile”Enter the path of the Xml file you saved”
lv_agentname=Environment.Value ("agentname")
lv_password=Environment.Value ("password")
systemutil.Run"C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
dialog("Login").WinEdit("Agent Name:").Set lv_agentname
dialog("Login").WinEdit("Password:").Set lv_password
dialog("Login").WinButton("Cancel").Click
Step 9: Execute the Script and Analyze the Result.
33.2. Data Table Method:
By using the Data Table method we are Checking the Functionality for the application with Multiple number of inputs.
There are two types of Data Table Testing.
· Internal Data Table Testing.
· External Data Table Testing.
a. Internal Data Table Testing:
It is nothing but just applying the multiple number of inputs through the Defined Time Data Table in the Qtp.
Step 1: Enter all the Scripts for the Application in the Expert View.
Step 2: Go to the Keyword View and Parameterize the Templates and Its Values to the Defined Time Datatable.
Step 3: Through the Defined Time Data Table just apply the Multiple No of Inputs.
Step 4: Execute the Script to analyse the Result.
b. External Data Table Testing:
It is nothing but just applying the multiple number of inputs through the External File i.e. Excel Sheet.
Step 1: Open the Excel sheet, and enter the Templates and its Value that you want to check the functionality of the application.
e.g. agentname and its value, and Password and its value.
Step 2: Save the Excel Sheet as .xls.
Step 3: Open the Test in the QTP.
Step 4: Enter the Script as
E.g.: datatable.AddSheet"Arcus"
datatable.ImportSheet"path","Name of the Sheet in Excel","Arcus"
rc=datatable.GetSheet("Arcus").getrowcount
msgbox rc
For i=1 to rc
datatable.SetCurrentRow (i)
dialog("Login").WinEdit("AgentName:").Setdatatable.Value("agentname","roles")
dialog("Login").WinEdit("Password:").Setdatatable.Value("password","roles")
Dialog (“Login”).WinButton (“Cancel”).click
Next
Step 5: Execute the Script two analyze the Result.
No comments:
Post a Comment