Forum Discussion

MattMauger's avatar
MattMauger
Occasional Contributor
7 years ago

Object Not Found when Process is Closed and Reopened

Hi, 

 

I've been having an issue when my application is closed and reopened in the same test (or test suite). A test will run successfully the first time but if the exact same test is run again the objects cannot be found.

 

The objects have the exact same definition when viewed through the object explorer. The only difference between the instances as far as I can tell is the process Id. I have done several different checks and the original instance is definitely fully closed before the other instance opens. 

 

The error is either object not found or JavaScript runtime error RPC Server is undefined. 

 

All my variables are defined in a separate unit and evaluated when needed, if I use the same definition but a different name for the variables it works fine. I'm thinking test complete is still storing the original definition somewhere. I've tried using RefreshMappingInfo to redefining the process, this does remove the processes definition but does not solve the issue when it is redefined. 

 

I'm still quite new to TestComplete so sorry if this is obvious.

 

Thanks for your help, 

 

Matt

 

  • I've realised and solved the problem, I was saving the objects back over the definitions in my Variables Unit (I started doing this to save the number of variables I needed to define when I first started making tests). Thanks for your help 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    How are you identifying the object?  Are you using NameMapping to do the object identification?  Or are you using some other method?  If you're capturing the process using something other than NameMapping, the process object is no longer valid when the process is closed and then re-opened because assigning the process that way assigns the specific process.  If you reference the process using NameMapping, it does a check to see if the process is present and, if so, returns what it finds rather than storing the information from a previous instance.

  • MattMauger's avatar
    MattMauger
    Occasional Contributor

    Hi, thanks for the quick reply,  I'm not using NameMapping no, I've written them out as strings in a separate unit and using eval() to call them. 

  • MattMauger's avatar
    MattMauger
    Occasional Contributor

    I've realised and solved the problem, I was saving the objects back over the definitions in my Variables Unit (I started doing this to save the number of variables I needed to define when I first started making tests). Thanks for your help 

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      As I understand it, you've basically, in code, replicated the NameMapping feature to some extent but simply by using an "eval" to assign to a variable a current object.  

      While it works to some extent, as you noticed, this has some inherent problems and can end up with performance problems, code maintenance problems when hierarchies change, etc.  I would recommend investigating the NameMapping feature and using it instead of your code method.