cancel
Showing results for 
Search instead for 
Did you mean: 

Performance Issue with using GetPropertyValue and checkProperty with "Exists"

SOLVED
wmtan01
Contributor

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).

 

1 ACCEPTED SOLUTION

Accepted Solutions
AlexKaras
Community Hero

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

@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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

5 REPLIES 5
Marsha_R
Community Hero

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

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
Contributor

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

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
Community Hero

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

@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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

wmtan01
Contributor

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

It does help a bit with understanding. Thanks! 

 

There are a lot of things that on "theory" would behave the same way but it doesn't and this one I guess is one of those.

AlexKaras
Community Hero

Re: Performance Issue with using GetPropertyValue and checkProperty with "Exists"

aqObject can be considered as a low-level code. Like Win API.

For example, see the description of its .EmptyObject and .EmptyVariant properties.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
New Here?
Join us and watch the welcome video:
Announcements