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.