Forum Discussion

sowmya_bs's avatar
sowmya_bs
Contributor
15 years ago

How to avoid the log message "Unable to find the object 'xxx' "

Hi

I am trying to find an object existance on the page using this below code.



If DialogBoxObject.btnOK.Exists = True Then

   .... ..



End If



But Testcomplete logs an error message "Unable to Find the object btnOK"

This is a log message logged by TestComplete and it points to the statement -DialogBoxObject.btnOK.Exists



I am not sure if it is related to TestComplete settings as i have noticed the same piece of code being used in other script does not log this message as error.



Anyone let me know how to avoid this to be logged as an error message.?



-Thanks

Sowmya BS





  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Sowmya,



    It looks like you are using NameMapping in this test project.

    If this is the case, you should use WaitNamedChild function to avoid error in the log if the sought for object ws not found.

    E.g.:

    If (DialogBoxObject.WaitNamedChild("btnOK", 10000).Exists) Then

      ' button was found

    End If



    See "WaitNamedChild Method" help topic for more details.
  • This code worked fine when the 'btnOK' was found on the page. It did not log any error message in the log file.

    But when the 'btnOK' is existing it fails to identify it and the script fails there.

    I have the 'btnOK' in the namemapping.

    Here is the below code



    If (DialogBoxObject.btnOK.Exists) Then

    (this above line is replaced with -  If (DialogBoxObject.WaitNamedChild("btnOK", 10000).Exists) Then

        DialogBoxObject.btnOK.Click()

    Else

        DialogBoxObject.btnYes.Click()

    End If



    but this new line makes the script wait for btnOK, it does not find it even the object exists.

    Where am i going wrong?
  • Hi Sowmya

            I have same kind of problem which  you have.I have been working on it for the past few days. Please tell me if you found any solution for this problem.I will tell you if i found any solution for this



    sai_siddhu451@yahoo.co.in



    You can contact me here



    Thanks in advance
  • Hi,



    Check the recognition criteria in your Name Mapping scheme. Most probably, the button is mapped by properties which have unstable values. Also, try obtaining it with the WaitAliasChild method.
  • the dumb workaround i use for this kind of issue is log.enabled = false before the obj.exists and log.enabled = true after.

    I tried all possible workarounds like waitwpf object etc.  But when i try to look if it exists or not, I get error logs.  So i use this for the timebeing..



    Please post the result if you find any...

  • Hi All,





    This error in the log is caused by the fact that TestComplete cannot find an object by the mapping criteria specified in the Name Mapping tree. It is possible that the actual object that is not found is a parent object of the needed object. The exact object which is not found is specified in the 'Missing Object' section of the message posted to the Remarks pane along with the original error. You need to find this 'missing' object in the Name Mapping tree and make sure that it is mapped by properties that provide reliable and unique identification of the problematic object.





    If you cannot find out what's wrong with your Name Mapping scheme, please contact us via the Contact Support form and send us your project suite along with the log of the failed execution.