1) Data Driven Testing through an External Excel Sheet
Set myExcel=Createobject("Excel.Application")
Set myFile=myExcel.workbooks.open ("C:\Documents and Settings\admin\My Documents\gcreddy.xls")
Set mySheet=myFile.worksheets("Sheet1")
Rows_Count=mySheet.usedrange.rows.count
For i= 1 to Rows_Count
Agent=mySheet.cells(i,"A")
pwd=mySheet.Cells(i,"B")
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"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set Agent
Dialog("Login").WinEdit("Password:").SetSecure pwd
Dialog("Login").WinEdit("Password:").Type micReturn
Window("Flight Reservation").Close
Next
2) Exporting Data from a Database to an Excel Sheet
Dim con,rs
Set con=createobject("adodb.connection")
Set rs=createobject("adodb.recordset")
con.provider="microsoft.jet.oledb.4.0"
con.open"C:\Documents and Settings\admin\My Documents\gcr.mdb"
rs.open"select*from Login",con
Set ex=createobject("Excel.Application")
Set a=ex.workbooks.open("C:\Documents and Settings\admin\My Documents\gcr.xls")
Set b=a.worksheets("sheet1")
i=1
Do While Not rs.EOF
b.cells (i,1).value=rs.fields("agent")
b.cells(i,2).value=rs.fields("password")
rs.movenext
i=i+1
Loop
a.save
a.close
For QTP Information:
www.gcreddy.com
For Manual Testing:
www.gcreddy.net
For more QTP Information & Scripts visit: www.gcreddy.com
2
For Manual Testing docs visit: www.gcreddy.net
Description
vb script excel object model scripts for qtp testing.
Presentation Transcript
Your Facebook Friends on WizIQ