Forum Discussion

SmartUrsula's avatar
Occasional Contributor
7 years ago

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 sub...
  • tristaanogre's avatar
    7 years ago

    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 {

    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 page

    2) 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.