Forum Discussion

TKRK's avatar
TKRK
Occasional Contributor
2 years ago

Not able to use Find Object and call object method in keyword tests to validate data

Call Object Method

 
 

 

 

find Object - I am using wText property

 

 

I am not sure where I am making a mistake.

 

The same test works fine with Propertycheck point. 

 

I am trying to use waitproperty in the call object and find object and then compare the values, is this a wrong approach.

  • The following example, will check if the object exists i.e. 'Click Me!' button. If it does exist, then it logs 'Object exists' else 'Object does not exist'.

    If the object does not exist, TC will wait a number of seconds before continuing. The delay is based on playback settings.

     

    To check the property value of an object, the object must exist.

  • The methods that you use, you should read the documentation of Result Value that's returned.

     

    For example, if the property checkpoint value matches, the checkpoint logs a success message, otherwise, it logs an error message. It does not throw an error. If the Find method does not match the search criteria, it returns a stub object that only contains the Exists property equal to False. It does not throw an error. Since these methods do not throw an error, try...catch will not work. Ensure you understand the difference.

     

     

    • TKRK's avatar
      TKRK
      Occasional Contributor

      Experiments!

       

      I am validating expected value against actual value. I want to make sure that the object is available before the validation happens, so I am using waitproperty, then in the property name and this could be totally wrong, I am using object.text and comparing it with the parameter value, if you see the last screenshot, you might get the idea. Anyways I could be totally wrong. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The following example, will check if the object exists i.e. 'Click Me!' button. If it does exist, then it logs 'Object exists' else 'Object does not exist'.

    If the object does not exist, TC will wait a number of seconds before continuing. The delay is based on playback settings.

     

    To check the property value of an object, the object must exist.

    • TKRK's avatar
      TKRK
      Occasional Contributor

       

       

      Am understanding try catch concept correctly? Am I understanding waitProperty correctly? my understanding is other then the default time 10000 sec, TC waits for another 10s for object to be visible and then it does the Actions on the object, I guess I am asking questions that are not not related to my initial question.

       

      Also is the below keyword test wrong, if the page is taking time to render and the object is not available, at least this is what I understood, because when I use object exist, many times the test fails because the object is not there, so I was reading on some of the material and i found waitproperty, now I might me using is completely wrong, but does the screenshot below makes sense or this is not the correct way to implement and I should use obj.exist and then use propertycheck and it is comparing correctly.

       

       

       

       

      another thing I wanted to ask, do I need to use try catch if object does not exist, is there any event handler that I can configure in the test complete to catch object not found exception. I am new to TestComplete 🙂

      try {

      if (object.exist) 

          propertycheck

      }

      catch {

      log.message

      }

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    The methods that you use, you should read the documentation of Result Value that's returned.

     

    For example, if the property checkpoint value matches, the checkpoint logs a success message, otherwise, it logs an error message. It does not throw an error. If the Find method does not match the search criteria, it returns a stub object that only contains the Exists property equal to False. It does not throw an error. Since these methods do not throw an error, try...catch will not work. Ensure you understand the difference.