Forum Discussion

wmtan01's avatar
wmtan01
Contributor
4 years ago

Performance Issue with using GetPropertyValue and checkProperty with "Exists"

Hi,

 

I'm not sure if someone has already noticed this before but I think it might be worth sharing and asking people about their opinions on it.

 

So normally we use Property Checkpoints and Get Property Value in the KWTs and recently started using them in scripts as well. In KWTs we would set the auto-wait timeout to be of lower value so we don't spend long waiting times for the object.

 

Now I noticed that the performance of the two steps here are very obvious:

 

Sub getExistenceSTYLE1(object)

     timeout = Options.Run.Timeout

     Options.Run.Timeout = 1000 //our team's agreed upon checkpoint timeout

    getExistenceSTYLE1= aqObject.GetPropertyValue(object, "Exists")

     Options.Run.Timeout = timeout

End Sub

 

Sub getExistenceSTYLE2(object)

     timeout = Options.Run.Timeout

     Options.Run.Timeout = 1000 //our team's agreed upon checkpoint timeout

     getExistenceSTYLE2= object.Exists

     Options.Run.Timeout = timeout

End Sub

 

so Style2 is actually respecting the timeout while Style1 does not which I don't really understand (maybe someone can explain it). So we ended up switching to Style2 exclusively for checking "Exists" property, this applies to both getting the property and checking the property. I discovered that this is actually how the On-Screen action is built, apparently for properties that are included in the IfObject options (Exists, Visible..) it is better to directly access those properties with object.Property instead of doing aqObject.GetPropertyValue(object, Property).

 

  • wmtan01 :

    Hi,

     

    Thank you for your observation and sharing the result.

    Considering your result, my opinion and explanation is like this:

    -- object.Exists considers timeout setting because TestComplete 'knows' that the code works with the onscreen object from the Object Browser tree;

    -- aqObject.GetPropertyValue(object, "Exists") does not consider timeout because .GetPropertyValue() method works with plain COM object and has no reason to wait until the object appears if it does not exist at the moment of call. Note that  aqObject.GetPropertyValue() can be used to get a value of some property for any COM object. This is a generic method and it is not bound to onscreen objects from Object Browser tree.

     

    Hope, this explains the situation and corresponds to the implementation.

     

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What kind of opinion are you looking for?  As you said, it's built to do it with using the object.Property options faster, and I do that wherever I can, even when it's not an if.  It's a more direct call to the object and it makes sense to me to do it wherever that's available.  I only use the aq functions if I can't do what I want directly.

    • wmtan01's avatar
      wmtan01
      Contributor

      Honestly I was expecting aqObject.GetPropertyValue(object, "Exists") to at least behave closely with object.Exists. And I was wondering why aqObject.GetPropertyValue(object, "Exists") did not respect the Options.Run.Timeout setting?

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        wmtan01 :

        Hi,

         

        Thank you for your observation and sharing the result.

        Considering your result, my opinion and explanation is like this:

        -- object.Exists considers timeout setting because TestComplete 'knows' that the code works with the onscreen object from the Object Browser tree;

        -- aqObject.GetPropertyValue(object, "Exists") does not consider timeout because .GetPropertyValue() method works with plain COM object and has no reason to wait until the object appears if it does not exist at the moment of call. Note that  aqObject.GetPropertyValue() can be used to get a value of some property for any COM object. This is a generic method and it is not bound to onscreen objects from Object Browser tree.

         

        Hope, this explains the situation and corresponds to the implementation.