|
发个比较当前窗口和BMP文件的例子吧,QTP不支持 整个window的比较!
我自己修改了一下,可以把错误的结果输出到result里!
'**********************************************************************
'Function: CompareBitmap
'Paremeter:
' obj - instant of window
'fileExp- the file of the expected bmpfile with the whole path
'Note:
' this function is usted to compare the expected bmpfile with the current window (this feature can't do by QTP checkpoint)
' Modification history :
' Sr Date Modified By Why & What is modified
' 1. 2006.7.12 Anson new
'**********************************************************************
Public Function CompareBitmap (obj, fileExp)
Dim oCompareUtil, fileAct
' Temporary file for storing the current object bitmap
fileAct = environment("ResultDir") & "\" & CStr(RandomNumber (1,10000)) & ".bmp"
obj.CaptureBitmap fileAct, TRUE
' Create a Compare Util Object
Set oCompareUtil = CreateObject("Mercury.FileCompare")
' Compare and Report results
IF oCompareUtil.IsEqualBin(fileExp, fileAct, 0, 1) then
Reporter.ReportEvent micPass, "Bitmap Check", "Expected bitmap file: " & fileExp & " matched the actual object bitmap "
CompareBitmap = TRUE
ELSE
Reporter.ReportEvent micFail, "Bitmap Check", "Expected bitmap file: " & fileExp & " did not match the actual object bitmap "
'Output expected bitmap to results
Reporter.ReportEvent micDone,"Expected bitmap:","<<img src='" & fileExp & "'>>"
'Output actual bitmap to results
reporter.ReportEvent micDone,"Actual bitmap:","<<img src='" & fileAct & "'>>"
CompareBitmap = FALSE
END IF
End Function |
|