Forum Discussion

Babulu's avatar
Babulu
Contributor
8 years ago

How to check the images difference in region checkpoint

Sub ImageDifference()
dim Pict1,Pict2

Set Pict1 = ProjectSuite.Path & "ABC\Stores\Regions\imagePng1.png"
Set Pict2 = ProjectSuite.Path & "ABC\Stores\Regions\imagePn1.png"

Pict1.LoadFromFile("D:\123.png")
Pict2.LoadFromFile("D:\1231.png")

' Comparing the images using the Compare method
If Not Pict1.Compare(Pict2) Then
Log.Picture(Pict1)
Log.Picture(Pict2)
Log.Error "The compared images are not identical"
End If

2 Replies

  • JuliaBernikova's avatar
    JuliaBernikova
    SmartBear Alumni (Retired)

    Hi,

     

    Could you please describe it in more detail what problems you're having, what task you're trying to perform, whether you get any errors?

     

    By the way, it is possible to create a region checkpoint using the Create Region Checkpoint option from the Code Editor's toolbar. See the "Creating Region Checkpoints" article for more info.

  • YuriPeshekhonov's avatar
    YuriPeshekhonov
    SmartBear Alumni (Retired)

    Hello,

     

    Try using the Compare Method. So, the code will be like this:

     

    Sub Test1
      Dim Pict1, Pict2 
      Set Pict1 = Utils.Picture
      Set Pict2 = Utils.Picture
    
      ' Loads the image from a file and posts it to the log
      Call Pict1.LoadFromFile("D:\Data\my_image.png")
      Call Pict2.LoadFromFile("D:\Data\my_image.png")
    
      If Not Regions.Compare(Pict1, Pict2) Then
        Log.Error("The compared images are not identical.")
      End If
    End Sub