Forum Discussion

slaugier's avatar
slaugier
Occasional Contributor
7 years ago
Solved

How to get the pixel tolerance value?

Hello,    I compare 2 files. My goal is to set a warning message if the pixel tolerance is below a certain value. An error message if it is up to this value. How can I get the exact pixelTolerance...
  • cunderw's avatar
    7 years ago

    I'm not sure of way to get the difference value returned from not matching values, but you specify the tolerance in your compare. 

     

    https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/compare.html

     

    But for what you're doing I don't think you really even need it. You could just nest compares with varying tolerances.

     

      let maxDifference = 20;
      // check if they're identical
      if(!pic_1.Compare(pic_2)) {
        // if they're more than maxDifference log error
        if(!pic_1.Compare(pic_2, false, maxDifference, false, 5, 0)) {
          Log.Error()
        } else {
          // they're different but acceptable log a warning
          Log.Warning();
        }
      }