|
比较当前窗口和BMP文件的VBScript
发个比较当前窗口和BMP文件的例子吧,QTP不支持 整个window的比较!
我自己修改了一下,可以把错误的结果输出到result里!
这次 我修改了 输出的结果 可以把两个窗口 放在同一行上比较 比上次的脚本方便了一些 sdlkfj5
希望下次能解决 再显示一张 两个图片 不同点的图片 这个就能够实现winrunner 在这方面的功能了!!!
'**********************************************************************************
'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
' 2. 2006.7.17 anson modify HTML foramt of report
'******************************************************************************
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:","<<TABLE><TR><TD><img src='" & fileExp & "'></TD><TD>" & "<img src='" & fileAct & "'></TD></TR></TABLE>>"
'Output actual bitmap to results
' reporter.ReportEvent micDone,"Actual bitmap:","<<img src='" & fileAct & "'>>"
CompareBitmap = FALSE
END IF
End Function |
|