在軟件測試中QTP常用程序和函數

發表于:2009-06-30來源:作者:點擊數: 標簽:軟件測試qtpQTP程序函數
1.創建一個 vb s文件:TestVbs.vbs 內容如下: ’################################################################################## SubCloseWeb() ’此處可以用到描述性編程,把先期打開的IE窗口全關閉 DimWinIe,Ie,i,m SetWinIe=descrīption.Create(

1. 創建一個vbs文件:TestVbs.vbs
內容如下:
’##################################################################################
Sub CloseWeb()

’         此處可以用到描述性編程,把先期打開的IE窗口全關閉
Dim WinIe,Ie,i,m
Set WinIe=descrīption.Create()
WinIe(\"regexpwndtitle\").value=\" Microsoft Internet Explorer\"  ’所有頁面的regexpwndtitle屬性值都是\" Microsoft Internet Explorer\",也可以用其他屬性
Set Ie=desktop.ChildObjects(WinIe)
m=Ie.count
For i=1 to m
        Ie(i-1).close                 ’ 0為最后打開的一個,可關閉打開的幾個,,循環改成for i=1 to m
Next
End Sub
’##################################################################################



function TestVbs(format)
        msgbox \"參數是\" & format 
end function


’#################################################################
’#################################################################
’往文件里面寫內容
’第一個參數 文件的路徑
’第二個參數:寫入的內容
’第三個參數:寫入的格式(\"Appending/Writing\")
’ See also \"FileSystemObject\"
Sub Write2File(FilePath,content,style)
   Dim fso,f
   Dim stl
        If Ucase(style)=\"APPENDING\" Then 
                stl=8
        else 
                if Ucase(style)=\"WRITING\" then 
                                stl=2
                else 
                                        reporter.ReportEvent 1,\"參數錯誤\",\"Writing <\" & FilePath &\">:<\"& content &\">With<\" & style & \">\" 
                                Exit Sub
                end if
        End If  
   Set fso=CreateObject(\"scrīpting.FileSystemObject\")
   Set f=fso.OpenTextFile(FilePath,stl,true)
   ’content=\"寫入的第一行內容\"
   f.WriteLine(content)
   f.Close
   Set f=nothing
   Set fso=nothing

End Sub
’#################################################################

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97