Forum Discussion

mrezahoseini's avatar
mrezahoseini
Contributor
9 years ago
Solved

How to compare two images

Hello   I've got two images, the location of one of them is on my hard disk and other one has been mapped on my the name mapping of my TC, how can I compare these two images with each other with sc...
  • osaid_ahmad's avatar
    osaid_ahmad
    8 years ago

    You can try Picture.Compare (https://support.smartbear.com/viewarticle/72669/) as suggested by somebody else also.

     

    Cosider the following VB Script taken from the above link: 
     

      Set imageOnDisk = Utils.Picture 'to obtain empty picture object
      Set actualPicOnScreen = (Aliases.page.obj).Picture    'capture yourMappedObj's image
     

     imageOnDisk.LoadFromFile("D:\Data\img1.png")
      
      ' Comparing the images using the Compare method
      If Not imageOnDisk.Compare(actualPicOnScreen ) Then
        Log.Picture imageOnDisk, "Expected Image"
        Log.Picture actualPicOnScreen, "Actual Image"
        Log.Error "The compared images are not identical"
      End If

  • mrezahoseini's avatar
    mrezahoseini
    8 years ago

    Thank you very much indeed, it works for me