For more QTP Information & Scripts visit: www.gcreddy.


1) Data Driven Testing through an External Excel Sheet
1) Set myExcel=Createobject("Excel.Application") 2) Set ("C:\Documents and Settings\admin\My Documents\gcreddy.xls") 3) Set mySheet=myFile.worksheets("Sheet1") 4) Rows_Count=mySheet.usedrange.rows.count 5) For i= 1 to Rows_Count 6) Agent=mySheet.cells(i,"A") 7) pwd=mySheet.Cells(i,"B") 8) SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open" 9) Dialog("Login").Activate 10)Dialog("Login").WinEdit("Agent Name:").Set Agent 11)Dialog("Login").WinEdit("Password:").SetSecure pwd 12)Dialog("Login").WinEdit("Password:").Type micReturn 13)Window("Flight Reservation").Close 14)Next

2) Exporting Data from a Database to an Excel Sheet
1) Dim con,rs 2) Set con=createobject("adodb.connection") 3) Set rs=createobject("adodb.recordset") 4) con.provider="microsoft.jet.oledb.4.0" 5)"C:\Documents and Settings\admin\My Documents\gcr.mdb" 6)"select*from Login",con 7) Set ex=createobject("Excel.Application") 8) Set"C:\Documents and Settings\admin\My Documents\gcr.xls") 9) Set b=a.worksheets("sheet1") 10)i=1 11)Do While Not rs.EOF 12)b.cells (i,1).value=rs.fields("agent") 13)b.cells(i,2).value=rs.fields("password")

For Manual Testing docs visit:


For more QTP Information & Scripts visit:
14)rs.movenext 15)i=i+1 16)Loop 17) 18)a.close

For QTP Information:
For Manual Testing:

For Manual Testing docs visit:


Sign up to vote on this title
UsefulNot useful