Forum Discussion

kerriem's avatar
Occasional Contributor
2 years ago

How to check that an image Region does not exist any longer?


I am working on an automation script where i've used Regions Check function to check that a region (image) exists, then perform an action and want check that it is no longer present.

I'm using Python for my scripting and had tried this:


if not Regions.MainMenuUserPrefsFocus.Check(HomePg.NavBarRHDropdown.MainPanel.panelMainMenuContainer, False, False, 2165, 17):
   Log.Message("PASS - User Prefs NOT in Main Menu highlighted / in focus")
   Log.Warning("FAIL - User Prefs displayed in focus on Main Menu")


However, this is giving me failures in the log:

"Ambiguous recognition of the tested object." 

Followed by:

"The region checkpoint "MainMenuUserPrefsFocus" failed."

Followed by my Log message to PASS - User Prefers NOT in Main Menu ...


Is there a way to basically perform a negative Region check to check that a region is no longer displayed?


  • What is in the region when the first image is no longer there?  Could you check for that on the second pass?

4 Replies

  • Marsha_R's avatar
    Champion Level 3

    What is in the region when the first image is no longer there?  Could you check for that on the second pass?

  • Kitt's avatar
    Regular Contributor

    "Ambiguous recognition of the tested" object usually occurs because there're several objects which meet the same recognition criteria. Here are some troubleshooting steps recommended by the [TestComplete reference].


    However, it appears as though you are using name mapping to reference an onscreen object instead of a stored image, if this is the case you could just reference the mapped object with the waitAliasChild method and check for the Exists property and handle accordingly


    if (HomePg.NavBarRHDropdown.MainPanel.WaitAliasChild("panelMainMenuContainer" ).Exists):
      # returns exists=true if object found
      Log.Warning("FAIL - User Prefs found on Main Menu")
      # returns exists=false when object is not found
      Log.Message("PASS - User Prefs NOT found in Main Menu")

    [TC reference]


    but based on your log reference to the object being 'in focus', you may just be wanting to verify a property of the tested object which you could use the waitProperty method


    obj = HomePg.NavBarRHDropdown.MainPanel.panelMainMenuContainer
    if obj.WaitProperty("Enabled", True, 2000):
       # object is enabled
       Log.Warning("FAIL - User Prefs enabled on Main Menu")
       # object is disabled
       Log.Message("PASS - User Prefs NOT enabled on Main Menu")

    [TC reference]

  • kerriem's avatar
    Occasional Contributor

    Thank you both!
    I investigated the Ambiguous error a little more and yes - the properties were a bit 'vague' for NavBarRHDropdown.

    For the test itself, I've gone with the other suggestion though of looking for what is in the Region the 2nd time around, rather than focusing on checking that the original region isn't there any more.


    It would be nice though to have a method of checking it doesn't exist without slowing the test down, etc i.e. a negative check, but the workaround is sufficient for what I need.