Forum Discussion

hppedersen's avatar
hppedersen
Occasional Contributor
15 years ago

The window was destroyed during method execution.

Hi



I have made a script for selecting an item in popup menu, but when click on the item I got the error:

The window was destroyed during method execution.



Before the click I check if the app menu item exists and it does.



I have try with TestComplete 7.0 and 7.5, but get same problem.

The application is implemented in WPF.

What can I do?



Best Regards

B&K

Henrik Pedersen

8 Replies

  • I've solved this issue via a different means. I did not want to just hide the log entry but actually prevent the problem from occurring. Some experimentation and I found that adding a delay would in some cases provide enough time for the window to 'recreate' itself...the problem is that there is no finite delay time that worked reliably.



    So my solution was to create a function that would wait until the object is visible before interating with it.



    The function:



    function WaitFor(_propertyNames ,_propertyValues)

    {

       

        var PN = _propertyNames;

        var PV = _propertyValues;

        var Depth = 1000;

        var Refresh = true;



        Log.Message("Waiting for Property '"+PN+"' and '"+PV+"' to become visible...");



        while(!Aliases.BrowserWindow.Find(PN, PV, Depth, Refresh).Visible){

            //Wait until the object is visible before proceeding

        }



        Log.Message("Property is visible");    

    }




    To use it, I just call on the function immediately before the action I want to perform:



    var PropNames = new Array ("propertyname1", "propertyname2");

    var PropValues = new Array ("propertyvalue1", "propertyvalue2");

    WaitFor(PropNames, PropValues);

    Aliases.BrowserWindow.Find(PropNames, PropValues, 1000, True).Click();
  • Hi Henrik,



    Please verify the value of the Mouse movement delay property (right-click your project in Project Explorer | Edit | Properties | Playback). In case the value of the property differs from 0, please set it to 0.



    If the suggestion above does not help, please zip the entire project suite folder and send us the archive via the following web form:


    http://smartbear.com/support/message/?prod=TestComplete



    Also, please try to reproduce the issue with the Orders sample application (<TestComplete 7 Samples>\Open Apps\OrdersDemo\WPF) and let me know your results.
  • hppedersen's avatar
    hppedersen
    Occasional Contributor

    Hi Alex,


    Sorry for the late reply.


    The mouse movement delay was set to 0.


    But now I have found the reason for the problem, because the tests has run in earlier version of the application and the developers have tracked the change in the application to be changes from Standard Popup to a Popup Non topmost.


    Now the developer have change it back again to a Standard Popup menu and the test is running fine.


    Thanks for your time and good support.


    Best Regards


    Henrik Pedersen


  • sreeja's avatar
    sreeja
    New Contributor


    I found the same issue with my TC8.6.



    I an see that my recorded script is working perfect but the end of the run, it shows error with this message.



    All what i have done is - my virtual machine was very slow and my client created another one for me in Windows 7. I have recorded the script in the new environment and still in happens!



    Please any one help.
  • sreeja's avatar
    sreeja
    New Contributor


    BTW, before my OS was XP and now its Windows 7. It was working fine for 2-3 runs, then its stopped!!



    Please help me!!!!
  • Hi Sreeja,



    You are supposed to see the following text in the Additional Information section of the test execution log:



    Most likely, this error occurred because the tested object (window or control) or its parent object was deleted or recreated during the method call or before it. For instance, the window could be destroyed or recreated after you stored the object reference to a variable and before you called the object method through this variable.

    If the object is recreated, then to avoid the error, check the object's Exists property before calling the method, and if the object does not exist, obtain a reference to the new object.





    Have you tried following these recommendations? What were the results? What problems have you faced when debugging your test? If the debugging abilities of TC and/or the corresponding documentation are not enough for you to find out why your test behaves unexpectedly, feel free to share your improvement suggestions with us.



    If the recommendations above do not help you overcome the issue, please zip the entire project suite folder and send us the archive along with a detailed description of what you have tried to get rid of the error.
  • Hello,



    Me too, I found  the same error "the window was destroyed during method execution", after I performed a Click in a DexExpress Tree.

    I could not found a solution, but I think is't possible to ignore this error in GeneralEvents_OnLogError(Sender, LogParams)



    Does anybody knows how to ignore this error?



    Regards,

    Raluca

  • Hi,

    In the meanwhile I found the solution. We should do like this:




    function



    GeneralEvents_OnLogError(Sender, LogParams)





    {





      if (LogParams["Str"] == "The window was destroyed during method execution.")





        LogParams["Locked"] = true;





    }