Checking if object exists on different pages
Hey all, I'm new to this software and was wondering if I could get some help. I'm trying to run an automated test to go through pages in different directories. So say I have 3 pages, all with 1-3 subpages. I want to be able to go through all off them and click on the subpages if they exist. The problem I am having is that my page buttons all have different object aliases even though they are the same exact nodes. They jus appear to be different because of the way they appear in the tree. Is there a way to make the software check if the node itself exists and not the specific alias? Thank you I know this probably could have been worded better.
Well, if your objects are all mapped, you're actually halfway there. The Alias basically just let's TestComplete find the object so you can interact with it. To check for existance, you just go something like
var subpageButton1 = Aliases.browser.myPage.WaitAliasChild('mySubPageButton1', 1000); if (!subpageButton1.Exists) { Log.error('test fails'); } else { subPageButton1.Click() }
This leverages the mapped aliases to be used as object detection.
Another method is to not look for the Aliased object but to use a "FindChild" method call.
Basically, the test would go like this:
1) Navigate to page2) Call "FindChild" on that page to look for the specific sub page
3) If FindChild returns a non-null object, the sub page exists
At this point, you can use the Aliased object to actually interact with the buttons and sub pages.