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

com

1) Data Driven Testing through an External Excel Sheet
1) Set myExcel=Createobject("Excel.Application") 2) Set myFile=myExcel.workbooks.open ("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) con.open"C:\Documents and Settings\admin\My Documents\gcr.mdb" 6) rs.open"select*from Login",con 7) Set ex=createobject("Excel.Application") 8) Set a=ex.workbooks.open("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: www.gcreddy.net

1

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

For QTP Information:

www.gcreddy.com
For Manual Testing:

www.gcreddy.net

For Manual Testing docs visit: www.gcreddy.net

2

Sign up to vote on this title
UsefulNot useful