' Refresh Browser
Public Sub Refresh
Browser ("Creationtime:=0"). Refresh
Browser ("Creationtime:=0"). Sync
End Sub
Public Function Include (value)
Dim excelpath,tcnum,arrtemp
arrtemp = Split (Value, ",")
Excelpath = arrtemp (0)
Tcnum = arrtemp (1)
' Execute use case
Set oexcel = CreateObject ("Excel.Application")
Set Owookbook = OExcel.Workbooks.Open (Excelpath)
Set Otcwooksheet = OExcel.Worksheets.Item (Tcsheet). UsedRange
Set Otswooksheet = OExcel.Worksheets.Item (Tssheet). UsedRange
Tcrow=otcwooksheet.rows.count ' calculation of the number of cell rows used
Tsrow=otcwooksheet.rows.count
For i = 2 to Tcrow
Testcesesid = Oexcelutil.getcelldata (Otcwooksheet,i,col_testcaseid)
RunMode = Oexcelutil.getcelldata (Otcwooksheet,i,col_runmode)
If Testcesesid = tcnum and RunMode = "Yes" Then
For j = 2 to Tsrow
Tstcid = Oexcelutil.getcelldata (Otswooksheet,j,col_testcaseid)
If tstcid = Testcesesid Then
Tsevent = Oexcelutil.getcelldata (otswooksheet,j,col_event)
Tselement = Oexcelutil.getcelldata (otswooksheet,j,col_elenium)
Tsattribule = Oexcelutil.getcelldata (Otswooksheet,j,col_attribute)
Tsvalue = Oexcelutil.getcelldata (otswooksheet,j,col_value)
Select Case Tsevent
Case "Launch"
Okeyword.launch Tsvalue
Case "Refresh"
Okeyword.refresh
Case "click"
Okeyword.click Tselement,tsattribule
Case "Input"
Okeyword.input Tselement,tsattribule,tsvalue
Case "Sendkeys"
Okeyword.sendkeys Tsvalue
Case "selects"
Okeyword.selects Tselement,tsattribule,tsvalue
Case "MouseMove"
Okeyword.mousemove Tselement,tsattribule
Case "SSet"
Okeyword.sset Tselement,tsattribule,tsvalue
Case "CloseBrowser"
Okeyword.closebrowser
End Select
End If
Next
End If
Next
' Close Excel
Set Otcwooksheet = Nothing
Set Otswooksheet = Nothing
' Owookbook.save
Owookbook.close
oExcel.Quit
Set oexcel = Nothing
Set Okeyword = Nothing
Set Oexcelutil = Nothing
End Function
' Click
Public Function Click (ELEMENT,ODESC)
Browser ("title:=.*"). Page ("title:=.*"). Sync
Arrayproperty Element,odesc
Proname = Split (Opropertyname, ",")
Provalue = Split (Opropertyvalue, ",")
Set oelement = GetItemList (objpage,proname,provalue)
If Oelement.count = 1 Then
Oelement (0). Click
else if Oelement.count = 2 Then
Oelement (1). Click
End IF
End If
Set Opropertyname = Nothing
End Function
Public Function Sync
Browser ("Creationtime:=0"). Sync
End Function
' Calendar Time Control method
Public Function Calendarset (element,odesc,value)
Arrayproperty Element,odesc
Proname = Split (Opropertyname, ",")
Provalue = Split (Opropertyvalue, ",")
Set oelement = GetItemList (objpage,proname,provalue)
If Oelement.count = 1 Then
Oelement (0). Object.setattribute "Value", Value, "0"
End IF
End Function
' Save data, provide downstream business references
Public Function SaveData (element,odesc,svalue)
arrtemp = Split (svalue, ";")
Arrayproperty Element,odesc
Proname = Split (Opropertyname, ",")
Provalue = Split (Opropertyvalue, ",")
Set oelement = GetItemList (objpage,proname,provalue)
If Oelement.count = 1 and UBound (arrtemp) =2 Then
Select Case Arrtemp (2)
Case "InnerText"
Oexcelutil.writeexceldata arrtemp (0), arrtemp (1), oelement (0). Getroproperty ("innertext")
Case "Value"
Oexcelutil.writeexceldata arrtemp (0), arrtemp (1), oelement (0). Getroproperty ("value")
End Select
End IF
End Function
QTP keyword-driven framework method body encapsulation