Forum Discussion

kingsmartbear's avatar
kingsmartbear
Contributor
13 years ago

I got "Can not obtain the rectangle of the window with handle xxxxx" error.

 Hi All:



    I wrote a script to get all properties within objects to compare two versions of an application.



    I'm using VarType function before property is retrieved but I still getting error "Can not obtain the rectangle of the window with handle xxxxx".



    Please see attached screenshot to find all detail information about how this kind of error I got.



    My question is Can I get working around solution for it?



Thanks a lot in advance,



Allan

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Well, right at the top there is the "Exists" property which is False... so, you can't retrieve any properties for an object that does not exist, hence the error you're getting.



    Could you paste in the script that you're using to do the comparison?  It might be that you need to add in some "wait" routine of some sort to wait for the object to render, instantiate, etc., before you attempt your comparison.
  • Hi Robert:



       Thanks a lot for your fast reply.



        I retrieved this object from sys.process("xxx").vclobject("xxxx") during application running even I did refresh from object browser.



        It is very seldom to getting this kind of error occurred because I can not figure it out the condition when it happens.



        It may happen to window object or any other objects.



        I'll post my script when I got time.



    Thanks again,



    Allan
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    It is possible that, during the run, the object is not created by the time you get access to it. Scripts typically play back faster than real world so there are times when an object is referenced in script code but has not been instantiated in real-world in time.



    To get around that, there are specific methods that will wait for an object to be returned before moving on.  In your case I'd look into using the WaitVCLObject method (described at http://smartbear.com/support/viewarticle/17247/)



    You might also benefit from http://smartbear.com/support/viewarticle/12168/ as it describes different methods and abilities to wait for an object or process to be available before moving on to the next step of a test script.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Allan,



    Another possible reason might be the 'The window was destroyed during method execution' message for the SystemMenu member. This means that the watched window was closed and reopened which invalidated the reference stored in the watched Obj variable.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    I wrote a script to get all properties within objects to compare two versions of an application.


    On a side note, Allan, why don't you simply use object checkpoints for this purpose?
  • Hi Helen:



      Thanks a lot for your mentioned about object checkpoint.



       The one of reasons I do not use object checkpoint is that we need to tracking all properties for all objects to ensure any change made by developer should based on requirements or change requirements.



        Object may change from time to time and checkpoint may fail every time from regression testing perspective.



        Please correct me if something wrong.



    Thanks,



    Allan
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    The one of reasons I do not use object checkpoint is that we need to tracking all properties for all objects to ensure any change made by developer should based on requirements or change requirements.


    Are you retrieving the expected values for the comparison from an externally maintained "requirements" file? If you are, your solution is probably the way to go. Otherwise, you could give object checkpoints a try.





    Object may change from time to time and checkpoint may fail every time from regression testing perspective.


    Object checkpoints are, in fact, automatically updatable. When your application changes to meet new requirements, you can run the test with the Update options enabled for the checkpoints, and TestComplete will update the checkpoint expected values from the application. This is a built-in way to keep up with changes in the tested app.



    Just my 2 cents. Of course, TestComplete is just a tool, and how you leverage it is really up to you.