Forum Discussion

jaxjeanne64's avatar
jaxjeanne64
Occasional Contributor
13 years ago

Comparing Regions when date changes

I am testing a software that automatically updates the date everyday in regions that i am comparing. I then run manual regression tests the following morning. this causes a problem because the date always changes to the following day when comparing regions with Regions. compare.



So i was wondering if there was a different way that i could compare images/ regions when there is always a difference. Either by somehow 'blacking out' that date area or using a different function??

5 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    There are at least 3 ways how to solve your problem:


    • Using Transparent color to ignore some pixels during comparing

    • Using Tolerance parameter to ignore a specific number of differences

    • Searching for an image inside another one


    You can read about them in TC help system, see topic "Comparing and Finding Images - Specific Tasks"
  • You can specify a mask file to skip sections of an image comparison.  You can specify the mask image in the last argument of the compare function for picture objects.
  • jaxjeanne64's avatar
    jaxjeanne64
    Occasional Contributor
    Thank you all!

    I have experience with programming but not enough to figure out how to add this (Win32API["TRANSPARENT" ] where transparent = true, to my script of comparing the images (below):



    if(!Regions.compare("P5414 Verify dragging to the left.bmp",Sys["Process"]("progeny")["Window"]("Afx:00400000:0", "Progeny", 1)["Window"]("AfxOleControl90", "", 1) (transparent = true)));

      Log.error("P5414 Verify dragging to the left.bmp regions are not identical.");



    Help?
  • Hi Jacqui,



    Please try the following code snippet:





    if(!Regions["Compare"]("P5414 Verify dragging to the left.bmp", Sys["Process"]("progeny")["Window"]("Afx:00400000:0", "Progeny", 1)["Window"]("AfxOleControl90", "", 1), true))

       Log["Error"]("P5414 Verify dragging to the left.bmp regions are not identical.");





    Does it help?



    Also, if you need to use a helper variable that specifies whether the Regions.Compare method uses transparent colors or not when performing the comparison, you can declare this variable and assign the needed boolean value to it before calling the Compare method or when passing the variable through the method's parameters. For example:





    var transparent = true;



    if(!Regions["Compare"]("P5414 Verify dragging to the left.bmp", Sys["Process"]("progeny")["Window"]("Afx:00400000:0", "Progeny", 1)["Window"]("AfxOleControl90", "", 1), transparent))

       Log["Error"]("P5414 Verify dragging to the left.bmp regions are not identical.");

      

    // -- or --



    if(!Regions["Compare"]("P5414 Verify dragging to the left.bmp", Sys["Process"]("progeny")["Window"]("Afx:00400000:0", "Progeny", 1)["Window"]("AfxOleControl90", "", 1), transparent = true))

       Log["Error"]("P5414 Verify dragging to the left.bmp regions are not identical.");





    BTW, please note that the Regions.Compare method posts an appropriate message with results of the image comparison to the test log by default. The type of the message to be posted to the test log if the comparison fails is specified by the last parameter of the method, MessageType (by default, it specifies the warning message type). Thus, there is actually no need to check results of the Compare method and post error messages to the test log by yourself.