UFT offers a file-comparison utility that can be used as a COM object; exactly like the DeviceReplay
, as we have seen earlier in this chapter. This utility is extremely useful to compare pictures and other files storing binary data, by means of calling its IsEqualBin
method, the syntax being as follows:
obj.IsEqualBin FilePathname1, FilePathname2, plErrorCode As tagCompError, [pFlags As Long]
Where obj
is an instance of Mercury.FileCompare
, and plErrorCode
with value 0 (FC_NO_ERROR)
indicates an in file compare class showing no error, and pFlags
is an optional argument, which, with value 1 (FC_DIFF_SIZE)
, indicates an in file compare class showing difference of size.
Write the following code in Action
of your test:
Dim FileComparisonUtil Set FileComparisonUtil = CreateObject("Mercury.FileCompare") 'Compare two binary files (e.g., pictures) Print FileComparisonUtil.IsEqualBin(ExpectedFile, ActualFile, 0, 1)