Forum Discussion

Haiyangwhu's avatar
Haiyangwhu
Contributor
10 years ago

Control type issue

Hi,



I have a test case with simple flow:

1. click on button A, dialog B will be prompted

2. get buttons from dialog B and perform click on it



Dialog B is a WinForm object, and most of the time the flow works well, but sometimes it doesn't because test complete / execute doesn't know what control type of dialog B is, and treats it as a generic Widnow control. While window control doesn't have extented & .NET properties, that's why couldn't find dialog B by mapped alias.



Why above issue occurs, and how should i avoid it?



Thanks,

Ocean

5 Replies

  • Ravik's avatar
    Ravik
    Super Contributor
      Hi Ocean,



    Try like below code-



          Delay(...Specify time........)

          Set popupB = Sys.Process("iexplore", 2).FindChild("wndCaption","OK",100)

               IF popupB.Exists then

                popupB.click

                else  

                log.Message("Pop up B not yet Visible")

               End If       

      

    In this code first of all I am waiting some time (TC may need some time for synch)hence I am waiting and then searching specific caption from pop-up B like (OK).



    When I have found OK it will be click on it and go for next.



    It will be happen just because our Application and TC time execution not synched.
  • Hi Ravi,



    Thanks for your reply! 



    The controls i use are all mapped in NameMapping.tcNM, some of the control properties does not exists when the control is in 'Window' type.

    I also have my own WaitControlExist function which looks like below. Usually i'll wait for the control for 180 seconds. From automation log captures, the control i want already on screen within first 60 seconds, which means it failed to get synched in next 120 seconds.



    How long will TC takes to get synched with test App? Can i trigger the synch event in script?



    Thanks,

    Ocean




    function WaitControlExist(control, waitMilliseconds)


    {


        Log.Message(GetFunctionMsg(arguments));


        var endTime = aqDateTime.AddSeconds(aqDateTime.Now(), waitMilliseconds / 1000);


        while (aqDateTime.Now() <= endTime)


        {


            if (Exists(control))


            {


                Log.Message("Exists!");


                return true;


            }


            else


            {


                //Log.Picture(Sys.Desktop, "Not exists!", "Capture in WaitControlExist inside while loop.", pmNormal);


                Log.Message("Not exists!");


                Delay(5000);


            }


        }


        Log.Picture(Sys.Desktop, "Not exists!", "Capture in WaitControlExist outside while loop.", pmNormal);


     


        return false;


    }





    function Exists(controlItem)


    {


        Log.PushLogFolder(Log.CreateFolder(GetFunctionName(arguments)));


        try


        {


            Log.Message(GetFunctionMsg(arguments));


            // Check if the name mapping item refers to an existing object


            if (controlItem.WaitProperty("Exists", true, 2000))


            {


                return true;


            } 


            else 


            {


                // Refresh the mapping information to see if the object has been recreated


                RefreshObjects();


                return controlItem.WaitProperty("Exists", true, 2000);


            }


        }


        finally


        {


            Log.PopLogFolder();


        }


    }

     




    // Call this method if the object tree changes


    function RefreshObjects()


    {


        Aliases.Refresh();


        Aliases.RefreshMappingInfo();


    }

  • Hi Tanya,



    From topic 'Project Properties - General Open Applications Options', i get "Method invoke timeout - .... If the specified time period has elapsed and the execution has not been started, TestComplete posts an error message to the test log."

    However, there is no such error mesages are posted, and i think the setting is for 'Open' application. While the situation i met is more like the 'Open' application is not treated as 'Open'.



    I also met another similar issue yesterday:

    My application is developed by Java, there is a treeView control inside it. At the begining, i could view the treeView control in TC's Object Browser, and there was a Java icon ahead of the treeView control node. Then i had a test to perform Select/Click/Expand actions on a node of the tree. After the test was finished, the treeView node in Object Browser changed to 'Window ' type. It sounded the treeView control was no longer 'Open' anymore - the control was 'Open' again after relaunching the applicaiton.



    However i could not reproduce the issue on another test VM. I don't know why it happens, hope to get some answers from you.



    Thanks,

    Ocean





  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Ocean,

     


    The issue is mostly related to the fact that TestComplete loses the "openness" of your app. It can happen when some long or difficult processes take place in the app. The Method invoke timeout can make TestComplete wait longer until an object is fully loaded and ready for test. Set its value to more than 30000ms. Also, it makes sense to increase the value of Auto-wait timeout project playback properties.