Parametrization
Suppose we have 1000 odd entries of user name and passwords, It is difficult to validate the data by recording each entry. Rather, we can record one entry and parametrize the field values so that Data will be fetched out automatically. This is the beauty of Automation Testing which makes it one step ahead on Manual Testing.
Ways of Performing Parametrization:
1) Through Loop Statement
For Example To Browse through all Properties of a Properties collection:
Dim obj
Set obj= Description.create
obj("html tag").value= "input"
obj("type").value= "checkbox"
obj.count 'Will count total no. of descriptions defined in a collection
For each desc in obj
Name= desc.name
Value= desc.value
RE= desc.regularexpression
Next
2) Importing from DataBase
Create a Test Database
- Open MS Access
- Start Program> MS Office> MS Access> File> New> Select blank DataBase
- Enter Name of Database> Save with .mtb extn
- Creating table: Select Create table in Design View> Enter Field Name
- Entering Data into Table: Select Table> Enter the Data
- Create DSN & Import Data.
Please Note that DSN Creation is one time activity.
DSN Creation and Allign with Database to import data
- Open QTP.
- View> Data Table> Place the Mouse Pointer on Data Table> Right Click
- Sheet>Import> From Database. (Database Wizard opens)
- Choose 'Specify SQL Statements manually'.
- Click Next> Create> New> Select Driver type> Click 'Next'.
- Browse Path to Restore> enter DSN Name> Click Save> Next> Finish.
- Select> Browse the Data base and Select> Click OK
- Select DSN> Click OK> enter SQL statement (select * from login)> Finish
Default Path of DSN: C:\Program File\Common File\ODBC\Data Sources
3) From Notepad/Excel
Suppose there is a notepad with Agent Names and Passwords. Here, 1st line is treated as Column Header and Tab Spaces as Delimiters.
View>Datatable> Place the Mouse Pointer on Data Table> Right Click> File>Import from File>
( Browse the Path of the File)
To connect Test Data to the Test
Dialog ("Login").Activate
Dialog ("Login"). Winedit ("Agent Name:").Set "sumit"
Dialog ("Login"). Winedit ("Password:").Set "mercury"
1st way: Set Datatable ("Agent",1)
Set Datatable (2,1)
wait 2
2nd way: (using data driver wizard) goto Tools> data driver
Value Constants Parametrized
sumit 1 0
mercury 1 0
Add Value Parametrized
Click on 'Parametrized' then select 'Parametrized all'. Now, the screen will look like:
Set Datatable ("Agent", dtGlobalSheet)
Set Datatable ("Agent", dtGlobalSheet)
wait 2
4. Fetching Test Data Directly from Database:
option explicit
Dim con, rs
Set con= create object ("adodb.connection")
Set rs= create object ("adodb.recordset")
con.provider= ("microsoft.jet.oledb.4.0")
con.open "C:\.......emp.mdb"
rs.open "select * from login", con
do until rs.eof= true
| | |
| | |
| | |
rs.move next
loop
No comments:
Post a Comment