Forum Discussion

gabe1's avatar
gabe1
New Contributor
3 months ago
Solved

Workaround for MessageType when using Region.Check method

Hey. 

I need to move away from Region.Compare to Region.Check because of some expected tolerance in pixel values and Region.Compare only has PixelTolerance and not ColorTolerance. However, Region.Check seems to throw an error by default when there is a pixel difference, and does not take any "MessageType" parameters. It seem quite weird how these two methods work, as Region.Check is referred to be a simplified version of Regions.Check, yet it has more pixel comparison features, and less control over what happens when it does detect a difference. 

Is there a way I can convert/suppress that error Region.Check is generating and turn it into a Log.Warning? I need to keep the "picture" aspect of it to check the before/after results without stopping on a pixel diff. 

Thanks. 

  • I ended up doing this, which works but it just feels really stupid that 2 core Test Complete functions that are seemingly the same take different arguments. 

    1. Change playback options so tests don't stop on error
    2. Create a new onError handler
    3. Inside this, stop the execution for the current test only

    function GeneralEvents_OnLogError(Sender, LogParams) {
       if (!LogParams.MessageText.includes('The region checkpoint')) {
          Runner.Stop(true)
       }
    }

5 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I usually have something like this,

    Regions.Compare("icon.png", Aliases.panelOnePlaceTiles.panelTileType1.image, false, false, false, 0, lmWarning);

    using lmWarning

    • gabe1's avatar
      gabe1
      New Contributor

      lmWarning does not exist as a property on Region.Check though. That is the issue. It defaults to Error with no option to change it :(

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can also change the playback options, so the automation doesn't stop on error.

    • gabe1's avatar
      gabe1
      New Contributor

      That was the only other thing I could think of. The way our tests are designed is to stop on error as new tests assume the app is in the correct state. For example, if it's half way through a for loop and the app crashes, ignoring the error will end up in a weird state where TestComplete will try and execute the rest of the for loop functions on a non-existing app. Our tests are designed with that in mind, and each test is on its own unit, so if one fails, it doesn't affect the others. 

  • gabe1's avatar
    gabe1
    New Contributor

    I ended up doing this, which works but it just feels really stupid that 2 core Test Complete functions that are seemingly the same take different arguments. 

    1. Change playback options so tests don't stop on error
    2. Create a new onError handler
    3. Inside this, stop the execution for the current test only

    function GeneralEvents_OnLogError(Sender, LogParams) {
       if (!LogParams.MessageText.includes('The region checkpoint')) {
          Runner.Stop(true)
       }
    }