QTP轻量级框架系列(六)之测试过程屏幕截图保存

上一篇 / 下一篇  2016-04-18 18:05:05 / 个人分类:QTP

'==========================================================================

' NAME: User Login

' AUTHOR: heyl 

' DATE  : 2012-12-21

' COMMENT: 

'==========================================================================

Class ScreenCaptureEngine

 

             Public str_ScriptPath

                           Public  oFSO

                         

                           Private Sub Class_Initialize  

                                     str_ScriptPath = str_Test_Path&"Report\"

                                     str_ScriptPath = str_ScriptPath&GetTestName

                                     me.Createreporterfolder(str_ScriptPath)

             End Sub

                         

                          Private Sub Class_Terminate     

                          Set FSO = nothing

                          End Sub

           

                          'create a folder

                          Function Createreporterfolder(str_folderpath)

                          Dim fso, f

                          Set fso = CreateObject("Scripting.FileSystemObject")

                             If Not fso.FolderExists(str_folderpath)  Then

                             Set f = fso.CreateFolder(str_folderpath)

                             Set f = Nothing

                             Set fso = Nothing

                             Else

                             Set fso = Nothing

                             End If

                          End Function

 

                          Public Sub Report()

                           

                             Dim sFile

                             Dim sTimeStamp

                 

                         

                         

                             Set FSO = createobject("Scripting.FileSystemObject")

                             sTimeStamp = CStr(Now)

                             sTimeStamp = Replace(sTimeStamp , "\", "")

                             sTimeStamp = Replace(sTimeStamp , "/", "")

                             sTimeStamp = Replace(sTimeStamp , ":", "")

                         

                             sFile = str_ScriptPath

                             If Mid(sFile, Len(sFile),1) <> "\" Then sFile = sFile & "\"

                            

                             sFile = sFile & " " & sTimeStamp & ".png"

                         

                             While oFSO.FileExists(sFile)

                                      sFile = Mid(sFile ,1,Len(sFile)-4) & "_1" & ".png"

                             Wend

                            

                             Desktop.CaptureBitmap(sFile)

                           

                          End Sub

End Class

 

Set ScreenCapture = new ScreenCaptureEngine


TAG: QTP 截图

 

评分:0

我来说两句

Open Toolbar