How to check that an image Region does not exist any longer?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to check that an image Region does not exist any longer?
Hi,
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")
else:
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?
Thanks!
Solved! Go to Solution.
- Labels:
-
Script Tests
-
Web Testing
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is in the region when the first image is no longer there? Could you check for that on the second pass?
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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
EX:
if (HomePg.NavBarRHDropdown.MainPanel.WaitAliasChild("panelMainMenuContainer" ).Exists):
# returns exists=true if object found
Log.Warning("FAIL - User Prefs found on Main Menu")
else:
# returns exists=false when object is not found
Log.Message("PASS - User Prefs NOT found in Main Menu")
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
EX:
obj = HomePg.NavBarRHDropdown.MainPanel.panelMainMenuContainer
if obj.WaitProperty("Enabled", True, 2000):
# object is enabled
Log.Warning("FAIL - User Prefs enabled on Main Menu")
else:
# object is disabled
Log.Message("PASS - User Prefs NOT enabled on Main Menu")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad the workaround was sufficient!
You can add a feature request here for your "doesn't exist" comparison
https://community.smartbear.com/t5/TestComplete-Feature-Requests/idb-p/TestXCompleteFeatureRequests
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
