Forum Discussion

chicks's avatar
chicks
Regular Contributor
11 years ago

window was destroyed during method execution - after updating from 10.3 to 10.4



The web application that I am testing has a remove cards popup, and then a confirm remove button in the popup.   After updating TestComplete from 10.3 to 10.4  I am seeing "window was destroyed during method execution" most of the time  but not consistently) when I try to click on the "confirm removal" button.  In this case the button is not clicked.



The website code has not changed.

My code has not changed.  The only change is to TestComplete and TestExecute.



I am not using name mapping to find the objects. 

================================================

   parent = panel_groceryCards();

   if (retailerID  == FRN_PART_ID) {

      parent = panel_frnCards();

   }

   Click(myCards_remove_link(parent, card.number ) );    

  

   Click(myCards_link_confirmRemoval() );



=========================

function myCards_link_confirmRemoval() { return my_cards().FindChild(new Array("ObjectType", "idStr"), new Array("Link", "frnRemoveCardlink"), FIND_DEPTH); }





function myCards_remove_link(parent, cardNbr) {

 var temp = myCards_panel_cardNbr(parent,cardNbr);

 temp.Refresh();

 return temp.Parent.FindChild(new Array("ObjectType", "contentText"), new Array("Link","remove"),  FIND_DEPTH);

}





function my_cards(){return Sys.Process(browserToUse).Page("*");}





=================================================

  It does appear that when the removal  "works" the time between the "click to brign up the popup" and the "click to confirm removal"  is greater than 5 seconds.  In other words, the   function to find the confirm removal button is actually gets evaluated.



I am experimenting with delays and object refreshes but have not yet had any luck.

4 Replies

  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Curt,



    > Perhaps 10.4  is executing faster than previous versions so that it's actually finding both objects before the first gets destroyed?



    Yes, most probably this is the reason.

    The case is that:

    a) guys at SmartBear pays a constant attention to the performance of TestComplete;

    b) web applications almost always don't have objects ready in the memory (like the regular desktop applications do) but generate them after some data exchange with the server and;

    c) used objects are not destroyed immediately but after some timeout when they are collected by the garbage collector.



    Considering the above, my experience is that it is perfectly OK to write something like this (pseudocode) for the desktop:

    parent = panel_frnCards();

    Click(myCards_remove_link(parent, card.number ) );   

    Click(myCards_link_confirmRemoval() );



    But in the case of web applications, the same pseudocode must look like this:

    parent = FindAndWaitForExists(panel_frnCards());

    Click(FindAndWaitForExists(myCards_remove_link(parent, card.number )) );

    Click(FindAndWaitForExists(myCards_link_confirmRemoval()) );



    I.e., every time before you interact with some UI object, you must search for it and ensure that the target object exists. This means that you are giving enough time to the page background script code to communicate with the server and generate and display the required UI elements.

    The above approach may slow down tests execution speed, but increase their stability and your task will be to find an acceptable balance between code performance and stability of objects identification.

  • chicks's avatar
    chicks
    Regular Contributor
    I discovered that two objects matched the myCards_link_confirmRemoval() call.



    one under  **.Page(*).Panel(0) and one under **.Page(*).Panel("colorbox").  I changed the function to use "colorbox" as the parent.



    The only outstanding question is why this was working prior to the use of 10.4.

    Perhaps 10.4  is executing faster than previous versions so that it's actually finding both objects before the first gets destroyed?



  • chicks's avatar
    chicks
    Regular Contributor
    Hi Alexei,



    Thanks for your comments.  Very good explanation of needing to wait for web service objects and make sure they exist before using them.  It seems to me as if the case you describe is actually the opposite of what I encountered however.   With the new version of testcomplete,  a less specific find function was finding two matching objects.   In other words,  the problem was not that the object did not yet exist when I was looking for it, but that too many objects existed.



    Regards, Curt
  • AlexKaras's avatar
    AlexKaras
    Icon for Champion Level 1 rankChampion Level 1
    Hi Curt,



    Yes, you are correct.

    However, this problem can also be explained as a consequence of the improved TestComplete performance :) : if the problematic object (or its parent) was created by some page script code, then when the object becomes obsolete it is not destroyed immediately by some clean-up code (like it is implemented in native desktop applications), but after some time by the garbage collector process. So, it might be that garbage collector was able to clean up the object when TestComplete worked slower, but just don't have enough time now.