TESTEVERYTHING

Showing posts with label Mercury.FileCompare object. Show all posts
Showing posts with label Mercury.FileCompare object. Show all posts

Sunday, 22 May 2011

Compare bitmap file using QTP ( using Mercury.FileCompare object )

Hi All,
We can use QTP in-build method for File compare with the help of Mercury.FileCompare.
Here I am going to describe how to use that.

Rem variable to store the location of the expected bitmap file
strstoreBMPfile = “D:\rajivkumarnandvani.bmp”
Rem variable to store the location of the actual bitmap file
strActBMPfile = “D:\rajiv\runtimebmpfile.bmp”
Rem Activate the window
Window(“Flight Reservation”).Activate
Rem Capture the actual bitmap image from the application during run-time
Window(“Flight Reservation”).Static(“Static”).CaptureBitmap strActBMPfile , True
Rem here True will overwrite the file
Rem here we write the function for compare the bitmap file using qtp inbuild method Mercury.FileCompare.
Rem Function FnCompareTwoBMPfiles
Rem Description: this function Compares two bitmap images
Rem input pathExpBMPfile path of Expected bmp file
Rem input pathActBMPfile path of Actual bmp file
Rem return value 1 if both file are same ; 0 if different

Function FnCompareTwoBMPfiles( byval pathExpBMPfile , byval pathActBMPfile)
   rem create qtp file system object
   Set objMercuryFilecompare = CreateObject(“Mercury.FileCompare”)
   rem here we use binary compare
   if objMercuryFilecompare.IsEqualBin( pathExpBMPfile , pathActBMPfile , 0,1) Then
   rem if match then return 1
    FnCompareTwoBMPfiles = 1
  else
   rem if does not match then return 0
    FnCompareTwoBMPfiles = 0
  end if
  rem discard the object
  Set objMercuryFilecompare = nothing
End Function

Rem now we call this function
if FnCompareTwoBMPfiles(strstoreBMPfile ,strActBMPfile) = 1 then
    msgbox “ BMP file match”
else
    msgbox “BMP file not match”
end IF

Rem same thing we can use for other files also.

Which one is right ?

Translate







Tweet